刚才看张孝祥讲的内部类
在内部类前加static,怎么我调试不行啊,提示:Illegal modifier for the class InnerClass; only public, abstract & final are
permitted
类如下:
public class TestInnerClass {
private int i =1;
void test(){
InnerClass inner = new InnerClass();
inner.display();
};
}
static class InnerClass {
void display(){
System.out.println( "InnerClass ");
}
public static void main(String[] args) {
TestInnerClass t = new TestInnerClass();
t.test();
}
}
------解决方案--------------------是正确的
是要 加上 final
刚测试了,编译通过
呵