public class B { public static B t1 = new B(); public static B t2 = new B(); { System.out.println("构造块"); } static { System.out.println("静态块"); } public static void main(String[] args) { B t = new B(); } }
执行结果:
构造块
构造块
静态块
构造块
public class B { public static B t1 = new B(); public static B t2 = new B(); { System.out.println("构造块"); } static { System.out.println("静态块"); } public static void main(String[] args) { B t = new B(); } }
执行结果:
构造块
构造块
静态块
构造块
转载于:https://my.oschina.net/u/3847203/blog/3014479