Grandfather:
public class GrandFather {
public GrandFather(){
System.out.println("1");
}
static {
System.out.println("2");
}
{
System.out.println("3");
}
}
Father:
public class Father extends GrandFather{
public Father(){
System.out.println("4");
}
static {
System.out.println("5");
}
{
System.out.println("6");
}
}
Child:
public class Child extends Father {
public Child(){
System.out.println("7");
}
static{
System.out.println("8");
}
{
System.out.println("9");
}
}
Go:
public class Go {
public static void main(String[] args) {
Child c =new Child();
}
}
输出:2 5 8 3 1 6 4 9 7