9、JavaBean;

实体类

JavaBean有特定的写法:

  • 必须要有一个无参构造
  • 属性必须私有化
  • 必须有对应的get/set方法;

一般用来和数据库的字段做映射 ORM;

ORM:对象关系映射

  • 表-->类
  • 字段-->属性
  • 行记录-->对象

people表

id name age address
1 王刘1号 3 上海
2 王刘2号 18 上海
3 王刘3号 100 上海

 

 

 

 

 

class People{
    private int id;
    private String name;
    private int age;
    private String address;
}    

class A{
  new People(1,"王刘1号",3,"上海");
  
new People(1,"王刘2号",18,"上海");
new People(1,"王刘3号",100,"上海");

}

 

posted @ 2020-12-15 18:43  王刘study  阅读(61)  评论(0)    收藏  举报