As some sources say, the Java instance initialization blocks are executed whenever instance is created or right before constructor. But imagine this case:
public
There's a specific initialization procedure explained in the JLS, but let me distill the most critical parts:
This is why you see the behavior you do - because Main
is a subclass to Foo
, it isn't yet initialized, so its static block isn't been evaluated at that moment.
Consequently, Main
's constructor isn't executed until after Foo
's constructor, since there is an implicit call to super() in the subclass.