public class test extends test1 {
{
System.out.println("1");
}
public test(){
System.out.println("2");
}
static {
System.out.println("3");
}
public static void main(String args[]) {
new test();
}}
class test1{
static
{
System.out.println("4");
};
public test1 () {
System.out.println("5");
}
}
{
System.out.println("1");
}
public test(){
System.out.println("2");
}
static {
System.out.println("3");
}
public static void main(String args[]) {
new test();
}}
class test1{
static
{
System.out.println("4");
};
public test1 () {
System.out.println("5");
}
}
4
3
5
1
2
4, //初始化test1
3, //初始化test
5, //调用test1()
1, //初始化模块
2 //test()java 里面类的初始化和对象的初始化都要在类的体系从上往下执行
父类先,static先,然后main, new test()时,先父类
执行顺序是:43512
this class come from this book