Are fields initialized before constructor code is run in Java?

The correct order of initialisation is:

  1. Static variable initialisers and static initialisation blocks, in textual order, if the class hasn’t been previously initialised.
  2. The super() call in the constructor, whether explicit or implicit.
  3. Instance variable initialisers and instance initialisation blocks, in textual order.
  4. Remaining body of constructor after super().

See sections ยง2.17.5-6 of the Java Virtual Machine Specification.

Leave a Comment