JAVA学习-----容器和数据结构 |
1.一个完整的javabean要有set和get方法,以及一个无参的构造器.
source到generate getters and setters,生成:
source到generate constructor field,生成:
无参构造器:
2.例:表格数据存储_javabean和list结合存储整张表
①设置表格内容:
User user1=new User(1001,"张三",20000,"2018.5.5");
User user2=new User(1002,"李四",30000,"2005.4.4");
User user3=new User(1001,"王五",20,"2020.1.1");
②javabean按1操作。
③ 重写tostring:
public String toString() {
return "id:"+id+",name:"+name+",salary:"+salary+",hiredate:"+hiredate;
}
④list操作:(set与list相似)
或者map操作:
3.其他
①toString另一种重写: