如下调用
- public class Test1 {
- public static void main(String[] args) {
- A a = new A();
- System.out.println("a.x="+a.x );
- B b = a.new B();
- System.out.println("b.x="+b.x );
- b.func();
-
- }
- }
- class A {
- int x = 1;
- class B {
- int x = 2;
- void func() {
- int x = 3;
- System.out.println("x="+x );
- }
- }
- }
复制代码 |