前后两个报错:
The public type a must be defined in its own file
No enclosing instance of the type a.innerC.innerD is accessible in scope
像这样:
(代码:不管空格了)
public class a{
public class innerA{
public class innerB{
public void method4(){
System.out.println("a.innerC.innerD.this.var3:"+a.innerC.innerD.this.var3);
}
}
}
public class innerC{
public class innerD{
public int var3=23;
}
}
}
亲,什么意思,是教程写的有问题?
xecvagfrljcrwhgurczzkyphvvdftgidqtmtnlrtdcjuhmbngkfsovfdmqzdahjvoefnraympfxtuiaiwtsvpwhbamnhiuuogmjpcj
public class a {
public class innerA{
public class innerB{
public void method4(){
System.out.println("a.innerC.innerD.this.var3:"+a.innerC.innerD.var3);
}
}
}
public class innerC{
public class innerD{
public static final int var3=23;
}
}
}
第一个问题是你创建类时名字不是这个,新建一个名为a的class文件就行了,第二个问题将var3的前边加 static final 就可以访问了