现有数据:
{a,3}
{a,5}
{b,7}
想得到
{a:[{a,3},{a,5}]}
{b,7}
代码:
List<Student> stu = ****;
Map<String, List<Student>> map = stu.stream().collect(Collectors.groupingBy(e -> e.getName()));
现有数据:
{a,3}
{a,5}
{b,7}
想得到
{a:[{a,3},{a,5}]}
{b,7}
代码:
List<Student> stu = ****;
Map<String, List<Student>> map = stu.stream().collect(Collectors.groupingBy(e -> e.getName()));