A four-point principle of JavaBean
1. Must be a public class
2. Provide a public default constructor with no parameters
3. Property private
4. Property setter/getter encapsulation
2. Create a student persistence class
import java.util.Date; //student class public class Students { /* * Four principles of JavaBeans * 1. Must be a public class * 2. Provide a public default constructor with no parameters * 3. Attribute private * 4. Property setter/getter encapsulation */ private int sid; // student number private String sname; // name private String gender; // gender private Date birthday; // date of birth private String address; // address public Students() { } public Students(int sid, String sname, String gender, Date birthday, String address) { // super(); this.sid = sid; this.sname = sname; this.gender = gender; this.birthday = birthday; this.address = address; } public int getSid() { return sid; } public void setSid(int sid) { this.sid = sid; } public String getSname() { return sname; } public void setSname(String sname) { this.sname = sname; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } @Override public String toString() { return "Students [sid=" + sid + ", sname=" + sname + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + "]"; } }