java类中访问属性

package first;

public class for_protect {
    private int age=10;
    int number = 100;
    public void show(){
        System.out.println(number);
        System.out.println(this.number=1000);
        System.out.println(this.number);
        //private的变量用this
        //static变量用类名.变量
        //public 直接表示或this.number
    }
    public static void main(String args[]){
        for_protect test = new for_protect();
        test.show();
    }
}
原文地址:https://www.cnblogs.com/perl6/p/7215242.html