代码如下package innerclass;public class Inner_nested
{
static int i;
static int j;
public static class nested
{
int i;
int j;
public nested()
{
this.i = Inner_nested.this.i;
this.j = Inner_nested.this.j;
}
}
}会报错误 no enclosing of instance the type Inner_nested is accessible in scope为什么会这样 给我些嵌套类和内部类的解答 谢谢拉
{
static int i;
static int j;
public static class nested
{
int i;
int j;
public nested()
{
this.i = Inner_nested.this.i;
this.j = Inner_nested.this.j;
}
}
}会报错误 no enclosing of instance the type Inner_nested is accessible in scope为什么会这样 给我些嵌套类和内部类的解答 谢谢拉
this.j = Inner_nested.j;
这样就不会报错了
this.j = Inner_nested.j;
这样就不会报错了为什么那样改了就不会报错 ???请指教
确实哦。。static的内部类,是不能有外部类的实例引用的。