1. 程式人生 > >java類中訪問屬性

java類中訪問屬性

-s int java類 log font prot pro stat args

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

java類中訪問屬性