import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
class Student {
private String id;
private String name;
private boolean isMale;
private Date birth;
public Student() {
super();
}
public Student(String id, String name, boolean isMale, Date birth) {
super();
this.id = id;
this.name = name;
this.isMale = isMale;
this.birth = birth;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isMale() {
return isMale;
}
public void setMale(boolean isMale) {
this.isMale = isMale;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", isMale=" + isMale + ", birth=" + birth + "]";
}
}
public class StudentTest {
public static void main(String[] args) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
Student stu = new Student("00001", "Tom", true, dateFormat.parse("2000-01-01"));
System.out.println(stu);
}
}
温馨提示:答案为网友推荐,仅供参考