class Person{
String name;
int age;
public Person(){}
public Person(String name1,int age1){
name=name1;//方式1给成员变量赋值,不加this
age=age1;
}
public String getName(){
return name;
}
public void setName(String name,int age){
this.name=name;// 方式2给成员变量赋值,加this
this.age=age;
}
public int getAge(){
return age;
}
} |
|