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();
    }
}

 

posted on 2017-07-20 22:48  Perl6  阅读(1024)  评论(0编辑  收藏  举报

导航