public class Outer {
private int num = 10;
public class Inner {
int num=20;
public void show() {
int num=30;
System.out.println(num);
System.out.println(this.num);
System.out.println(Outer.this.num);
}
}
public void method() {
Inner i = new Inner();
i.show();
}
}
public class InnerDemo {
public static void main(String[] args) {
//创建内部类对象,并调用方法
// Inner i = new Inner();
Outer.Inner oi = new Outer().new Inner();
oi.show();
System.out.println("------------------------");
Outer outer=new Outer();
Outer.Inner ooi=outer.new Inner();
ooi.show();
System.out.println("------------------------");
Outer o = new Outer();
o.method();
}
}