注册 登录
编程论坛 JAVA论坛

这里使用static为什么出错了呢?

msl12 发布于 2015-10-01 23:28, 503 次点击
代码如下:

public class Test {
    public static void main(String[] args) {
        Cool cool=new Cool();
        Cool.Inner in=cool.new Inner();
    }
}

class Cool {
    private static int info=5;
   
    static class Inner {            //貌似这里编译出错
        public void print() {
            System.out.println(info);
        }
    }
}
2 回复
#2
林月儿2015-10-02 08:02
程序代码:
public class Test {
    public static void main(String[] args) {
//        Cool cool=new Cool();
        Cool.Inner in=new Cool.Inner();//貌似这里编译出错
    }
}

class Cool {
    private static int info=5;
   
    static class Inner {            
        public void print() {
            System.out.println(info);
        }
    }
}
#3
msl122015-10-02 11:38
好像略懂了一点儿,谢啦!
1