使用Java代码按照某属性进行分组


List<EmployeeVo> list = (List<EmployeeVo>) responseEntity.getBody().getObj();  //已经获取的值
for (EmployeeVo lists : list) {
List<EmployeeVo> empList = map.get(lists.getPostName()); //如果取不到数据,new一个新数组
if (null == empList) {
empList = new ArrayList<EmployeeVo>();
empList.add(lists);
map.put(lists.getPostName(),empList);
}else {
empList.add(lists); //如果之前已经存放过,就直接追加到原来的List里面
}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM