[Solved] What exaclty happens when a you call a constructor(new Class),do instance initializer blocks runs first? [closed]


The constructor executes in the following order:

  1. Calls the constructor of the superclass.
  2. Runs the instance initializer blocks in the order they were defined.
  3. Executes the rest of the body of the constructor.

I.e., both of your sysout statements execute just before the assignment n=10;. That’s how it should be. See JLS §12.5.

1

solved What exaclty happens when a you call a constructor(new Class),do instance initializer blocks runs first? [closed]