class B extends A{ public int m = m3(); public static int n = m4(); public int t = 0; public B(){ System.out.println(4); } public int m3(){ System.out.println(5); return 5; } public static int m4(){ System.out.println(6); return 6; } /** * 加载顺序: * 父类静态(不包括静态方法)--> 子类静态(不包括静态方法) --> sout(7) --> * 父类非静态变量 --> 父类构造器 --> 子类变量 --> 子类构造器 * * */ public static void main(String[] args) { System.out.println(7); A a = new B(); } }
执行结果:
3672154
转载于:https://www.cnblogs.com/Uzai/p/11254812.html
