类的加载过程
代码
public class Father{private int i = test();private static int j = method();static{System.out.print("(1)");}Father(){System.out.print("(2)");}{System.out.print("(3)");)public int test(){System.out.print("(4)");return 1;)public static int method(){System.out.print((5“);return 1;}
}public class Son extends Father{private int i = test();private static int j = method();static{Systen.out.print("(6)");}Son(){supper();// 子类构造器一定会调用父类,systen.out.print("(7)");}{system.out.print("(8)");}public int test(){Systen.out.print("(9)");return 1;}public static int method(){Systen.out.print((10)");return 1;}public static void main(String[] args){Son s1 = new Son();Systen.out.println();Son s2 = new Son();}
}
初始化子类,会先初始化父类