list 数组分类存到map中
2015-12-29 11:19
288 查看
//查询出来的所有学生List allStudents = null ;Map<String, List<Student>) map = new HashMap(
<String, List<Student>); for(Student student : allStudents){if(map.containsKey(student.getGroupNo())){ List students = map.get(student.getGroupNo());students.add(student);}else{ List students = new ArrayList();students.add(student); map.put(student.getGroupNo(),students);}}Student类:public class Student{private String groupNo;private String name;public String getGroupNo(){return groupNo;}public void setGroupNo(String groupNo){this.groupNo = groupNo;}public String getName(){return name;}public void setName(String name){this.name = name;}}
相关文章推荐
- SkylineGlobe 邻近度(Proximity)分析JavaScript源代码
- ionic开发环境搭建
- redis使用规范
- 网站--乱码
- C/C++语言的存储类型
- SVN使用教程总结
- 矩阵操作
- 单元测试利器之Jtester
- 9.1---上楼梯(CC150)
- jquery 表格行计算
- Linux kernel scriptes bin2c "\x"
- 多线程Socket通讯复习
- BFS宽度优先搜索思想
- 动态规划算法求lcs(最长公共子串)之Java代码实现
- java中的volatile的用法
- Android—解决Mapview和其他界面切换出现闪屏的问题(同事想法)
- 自定义属性
- iOS/iphone开发如何为苹果开发者帐号APPID续费
- C++指针比较的问题
- python知识-正则表达式