Below is a program in which there are two static block which in my opinion should be called at first notice but in order from top to bottom but that does not happen
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");
}
}