2009-07-06

Java things that make you go "hmm"


I am preparing myself to SCJP exam, and while reading preparation book I found "feature" I didn't knew about. Take a look at the following code:

public class Main {

 public static void main(String[] args) {
  new B();
 }

 static class A {
  public A() {
   System.out.println("A constructor");
  }
 }
 static class B extends A {
  {
   System.out.println("B init");
  }
  public B() {
   System.out.println("B constructor");
  }
 }
}


How do you think, what output will it generate?

No comments: