集合类继承,验证加载顺序 public class Cbc extends Bbc{public static Cbc cbc = new Cbc();public static void main(String[] args) {System.out.println("进入程序入口了!");System.out.println("num的值:"+num);}public Cbc()
public class Cbc extends Bbc{ public static Cbc cbc = new Cbc(); public static void main(String[] args) { System.out.println("进入程序入口了!"); System.out.println("num的值:"+num); } public Cbc() { System.out.println("我是Cbc构造方法!"); } static { System.out.println("我是Cbc静态代码块!"); } } class Bbc extends Abc { public static Bbc bbc = new Bbc(); public Bbc() { System.out.println("我是Bbc构造方法!"); } static { Abc.num = 2; System.out.println("我是Bbc静态代码块!"); } } class Abc { public static Abc abc = new Abc(); public static int num = 1; public Abc() { System.out.println("我是Abc构造方法!"); } static { System.out.println("我是Abc静态代码块!"); }