java beans 的设计原则

1 公有的类

2 共有不带参数构造方法

3 私有属性

4 属性setter/getter方法 

 

 

 

 

 

Studnet类:

 

package com.ddwei.student;

import java.util.Date;

public class Student {

 // java beans 的设计原则  /**   * 1 公有的类 2 共有不带参数构造方法 3 私有属性 4 属性setter/getter方法   */

 private int pid;// 学号  private String name;// 姓名  private String sex;// 性别  private Date birthday;// 出生日期  private String address;// 家庭地址

 public Student() {

 }

 public Student(int pid, String name, String sex, Date birthday,    String address) {   // super();   this.pid = pid;   this.name = name;   this.sex = sex;   this.birthday = birthday;   this.address = address;  }

 @Override  public String toString() {   return "Student [pid=" + pid + ", name=" + name + ", sex=" + sex     + ", birthday=" + birthday + ", address=" + address + "]";  }

 public int getPid() {   return pid;  }

 public void setPid(int pid) {   this.pid = pid;  }

 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;  }

 public String getName() {   return name;  }

 public void setName(String name) {   this.name = name;  }

 public String getSex() {   return sex;  }

 public void setSex(String sex) {   this.sex = sex;  }

}

posted on 2017-12-19 18:47  菜鸟乙  阅读(92)  评论(0编辑  收藏  举报