class liangzhong03 {
public static void main(String[] args) {
person p = new person("张丹",17);
System.out.println(p.getName()+p.getAge());
person s = new person();
s.setName("张丹");
s.setAge(19);
System.out.println(s.getName()+s.getAge());
}
}
class person
{
private String name;
private int age;
public person(){
}
public person(String name,int age){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
}
我第一次写的时候,return后面什么都不加.然后创建对象的时候还加了一点
|
|