1. 实体类里面的属性都是私有的,即修饰词为private。
2. 私有属性使用公开的set和get方法操作。
3. 要求实体类有属性作为唯一值(一般使用id值)。
4. 实体类属性建议不使用基本数据类型,而使用基本数据类型对应的包装类。
(1)八个基本数据类型对应的包装类。
--int ->Integer
--char -> Character
--其他的都是首字母大写,比如:
boolean -> Boolean
byte -> Byte
short -> Short
long -> Long
float -> Float
double -> Double
(2)比如表示学生的学习成绩分数,int score,
-- 学生得了0分,int score = 0;或者 Integer score = 0;
-- 学生没有参加考试。int类型没法准确表达(=0只能表达没有成绩),而Integer score = null;却可以表达。