//定义一个学生类
public class Student {
//成员变量
private String name;
private int age;
private String address;
//无参构造方法
public Student() {
super();
}
//有参构造方法
public Student(String name, int age, String address) {
super();
this.name = name;
this.age = age;
this.address = address;
}
//失血模型,get和set
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
//重写toString方法
public String toString() {
return "Student [name=" + name + ", age=" + age + ", address=" + address + "]";
}
}
原文地址:https://www.cnblogs.com/private-mingmie/p/11826780.html