public class Test{
private int age; //这是成员变量
public Test(int age){ //这是构造方法
this.age = age;
}
public void setAge(int age){ //这是成员方法
this.age = age;
}
public static int getAge(){ //这是全局方法,加了static ,成员方法就会变成全局方法
return this.age;
}
}
相关文章: