When i initialize the static inner class i am expecting that outer class is also initialized and will print I should see this as well. however this is not happening and i am getting only class Main as a output
class AA {
static {
System.out.println("I should see this as well.");
}
public static class BB {
BB() {
Object o = Main.class;
System.out.println(o.toString());
}
};
}
public class Test {
public static void main(String[] args) {
new AA.BB();
}
}
Can some one help me , explaining this behavior.