代码:
public static void main(String[] args) {
A a=new A();
a.f();
}
class A{
private String name="A";
public void f(){
class B{
private String name="B";
public void show(){
System.out.println("A姓名为:"+A.this.name+", B姓名为:"+name);
}
};
B b=new B();
b.show();
}
}
输出结果为: