九、JavaBean
实体类
JavaBean有特定的写法:
①必须要有一个无参构造
②属性必须私有化
③必须有对应的get/set方法;
一般用来和数据库的字段做映射 ORM;
ORM:对象关系映射
①表——>类
②字段——>属性
③行记录——>对象
Person.java:
package com.ping.pojo;
//实体类一般都是和数据库中的表结构一一对应
public class People {
private int id;
private String name;
private int age;
private String address;
public People() {
}
public People(int id,String name,int age,String address) {
this.id = id;
this.name = name;
this.age = age;
this.address = address;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
retu