[Solved] Initializer blocks [closed]


Yes , it will print :

main
initializer

Your initializer will be called once you call the constructor of the c2.Your default constructor for class c2 implicitly looks like :

c2() {
  {
    System.out.println("initializer");
  }
}

Refer the JLS for 12.4.2. Detailed Initialization Procedure.

1

solved Initializer blocks [closed]