java对List中的Map按照某一个key的值相同的进行分组

import java.util.stream.Collectors

List params = []
Map temp = [:]
temp.put("id",1)
temp.put("name","qq")
temp.put("height","180")
params.add(temp)
temp = new HashMap()
temp.put("id",1)
temp.put("name","www")
temp.put("height","111")
params.add(temp)
temp = new HashMap()
temp.put("id",2)
temp.put("name","eee")
temp.put("height","222")
params.add(temp)

Map<Integer, List<Map>> groupBy = params.stream().collect(Collectors.groupingBy({ it.id}))
System.out.println(groupBy)

    原文作者:武六七
    原文地址: https://blog.csdn.net/w567wzf/article/details/105262106
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞