下面是一个程序,其中有两个静态块,在我看来应该在第一次通知时调用,但是按照从上到下的顺序,但这不会发生
public class StaticTest {
public static void main(String[] args) {
A a1 = new A();
A a2 = new A();
B b1 = new B();
}
}
class A {
static {
System.out.println("Static block of Class A");
}
{
System.out.println("Non-Static block of a instance of Class A");
}
public A() {
System.out.println("Constructing object of type A");
}
}
class B {
static {
System.out.println("Static block of Class B");
}
{
System.out.println("Non-Static block of a instance of Class B");
}
public B() {
System.out.println("Constructing object of type A");
}
}