public void aaa(){
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
map.put("dicId","aaa");
map.put("dicName","钢材");
map.put("dicDes","钢材1号");
list.add(map);
map = new HashMap<>();
map.put("dicId","bbb");
map.put("dicName","钢筋");
map.put("dicDes","钢筋1号");
list.add(map);
map = new HashMap<>();
map.put("dicId","111");
map.put("dicName","钢筋");
map.put("dicDes","钢筋2号");
list.add(map);
map = new HashMap<>();
map.put("dicId","ccc");
map.put("dicName","河沙");
map.put("dicDes","河沙1号");
list.add(map);
Map<String, List<Map<String, Object>>> collect = list.stream().collect(Collectors.groupingBy(this::customKey));
}
private String customKey(Map<String,Object> map){
return map.get("dicId").toString();
}
java8 对 List<Map, Object>> mapList 分组
最新推荐文章于 2024-08-22 19:49:44 发布