- class A {
- int x = 1;
- public class B {
- int x = 2;
- void func() {
- int x = 3;
- System.out.println("A:"+new A().x+"\r\nB:"+this.x+"\r\nfunc:"+x);
- }
- }
-
- public B getB(){
- return new B();
- }
- }
- //测试
- public class Test3{
- public static void main(String[] args) {
- A a=new A();
- A.B b=a.getB();
- b.func();
- }
- }
复制代码
不知道对不对,楼主看看吧 |