class A {
int x = 1;
class B {
int x = 2;
void func() {
int x = 3;
System.out.println( ? );
}
}
}
下面是这道题的代码,这个代码看不懂,求大神给点注释!而且我看有的人的答案是这样的System.out.println(new A().x + "," + new B().x + "," + x);这两种的区别在什么地方?能详细的说一下吗?
public static void main(String[] args) {
A xxx = new A();
A.B x = xxx.new B();
x.func();
}
}
class A {
int x = 1;
class B {
int x = 2;
void func() {
int x = 3;
//打印这3个x变量。
System.out.println(A.this.x+","+B.this.x+","+x);
}
}
}