class A {
int x = 1;
class B {
int x = 2;
void func() {
int x = 3;
System.out.println( ? );
}
}
}
答案:
打印语句中的内容为:"func_x="+x+"\nB_x="+this.x+"\nA_x="+A.this.x
打印结果为:
func_x=3
B_x=2
A_x=1
完整代码如下
* */
public class Test7
{
public static void main(String[] args)
{
A.B a=new A().new B();
a.func();
}
}
class A
{
int x=1;
class B
{
int x=2;
void func()
{
int x=3;
System.out.println("func_x="+x+"\nB_x="+this.x+"\nA_x="+A.this.x);
}
}
}