java nested class private variable

类里面能使用内部内的私有变量,长见识了

package one;

public class MyThread extends Thread {
    private int type;
    
    public MyThread(int type) {
        this.type = type;
    }

    @Override
    public void run() {
        System.out.println("MyThread run() type:" + type);
        int b = XX.a;   // OK
    }   
    
    
    
    private static class XX {
        private static int a = 3;
    }

}

class T {
    //int b = MyThread.XX.a;  //error
}

 

posted @ 2016-03-27 15:10  牧 天  阅读(112)  评论(0)    收藏  举报