javabean
- 必须要有一个无参构造函数
- 属性必须私有化
- 必须有对应的get/set方法
一般用来和数据库的字段做映射;
ORM:对象关系映射
表------>类
字段---->属性
行记录-->对象
id | name | age | address |
---|---|---|---|
1 | qwer | 10 | beijing |
2 | qwert | 20 | shanghai |
3 | qwerty | 30 | guangzhou |
class People{
private int id;
private String name;
private int id;
private String address;
}
class A{
new People(1,"qwer",10,"beijing");
new People(2,"qwert",20,"shanghai");
new People(3,"qwerty",30,"guangzhou");
}