~/ learn/ java-from-zero/ cards/ Initialization order: static, instance, and constructor
1 of 4

Type a static initialiser block

Type a static initialiser block

Answer

static { System.out.println("class loaded once"); }

Static blocks run once when the class is first loaded — before any instance is created. Use them to initialise complex static fields.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/73c99b6d-7e11-4548-89f4-9996c1c2a0d1/flashcard utf-8 LF