04-创建持久化类

新建一个类

类必须有以下特点:

1,必须是共有类
2,提供共有的不带参数的默认的构造方法
3,属性私有
4,熟悉使用setter/getter封装

生成一个代码如下:

import java.util.Date;

//学生类
public class Students {
    //必须是共有类
    //提供共有的不带参数的默认的构造方法
    //属性私有
    //熟悉使用setter/getter封装
    
    private int sid;//学号
    private String sname;//姓名
    private String gender;//性别
    private Date birthday;//出生日期
    private String 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 + "]";
    }
    
    
    

}

 

posted @ 2017-11-11 17:02  美好的明天  阅读(549)  评论(0编辑  收藏  举报