class Outer
{
private int num = 7;
private static int x = 8;
class Inner
{ int num = 9;
void print(){
System.out.println(x);
}
class Inner1
{ int num = 10;
public void method() {
int num = 11;
System.out.println("访问的是Inner1的method()"+num);//11
System.out.println("访问的是Inner1的成员变量num:"+this.num);//10
System.out.println("访问的是Inner1的num="+Inner1.this.num);//10
System.out.println("访问的是Inner的num="+Inner.this.num);//9
System.out.println("访问的是Outer的num="+Outer.this.num);//7 为什么不是Outer.Inner.this.num
}
}
}
}
public class InnerClassDemo
{
public static void main(String[] args)
{
Outer.Inner.Inner1 in = new Outer().new Inner().new Inner1();
in.method();
}
}