本帖最后由 喝龙血的我 于 2013-10-13 08:41 编辑
- <p>class StaticCode
- {
-
- private static StaticCode tt = new StaticCode();</p><p> private InstanceCode In = new InstanceCode();
- static
- {
- System.out.println("StaticCode类的静态代码块");
- }
-
- private StaticCode()
- {
- System.out.println("StaticCode类的构造函数");
- }
- {
- System.out.println("StaticCode类的构造代码块");
- }
-
- public static void main(String []agrs){
- }
- }
- class InstanceCode
- {
- static
- {
- System.out.println("Instance类的静态代码块");
- }
- {
- System.out.println("Instance类的构造代码块");
- }
- InstanceCode()
- {
- System.out.println("Instance类的构造函数");
- }
- 只是改变了一下修饰变成private,为什么会发生执行顺序的变化??
复制代码 |