package com.itheima;
/*
* 7、 在打印语句中如何打印这3个x变量?
class A {
int x = 1;
class B {
int x = 2;
void func() {
int x = 3;
System.out.println( ? );
}
}
}
*/
public class Test07 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//创建内部类对象
A.B oi = new A().new B();
oi.func();
}
}
class A {
int x = 1;
class B {
int x = 2;
void func() {
int x = 3;
System.out.println(x+"---"+this.x +"---"+new A().x );
}
}
} |
|