public class B {
static{
System.out.println("super static");
}
public B() {
System.out.println("super constructor");
}
}
public class
Test extends B{
static int value;
static {
value = (int)(Math.random()*40);
System.out.println("static with value "+value);
}
public Test() {
System.out.println("constructor");
}
public static void main(
String[] args) {
Test t = new Test();
}
}
In above piece of code, why is it that the static block in super class executes first?
Why not the static block from the class containing main?