- public class Test7{
- public static void main(String[] args){
- //调用内部类B
- A.B d=new A().new B();
- d.func();
- }
- static class A{
- int x = 1;
- class B{
- int x = 2;
- void func(){
- int x = 3;
- //this调用的是本类对象
- System.out.println(A.this.x+","+this.x+","+x);
- }
- }
- }
- }
复制代码
方法不是静态的,静态不能调用非静态 |