Java8实现List数据转一对多map

示例代码:

List<User> users = getUserList();
Map<Integer,List<User>>=users.stream().collect(Collectors.groupingBy(User::getAge));

以上示例代码是按照年龄纬度生成一个年龄对多个用户对象的map数据。

猜你喜欢

转载自blog.csdn.net/weixin_38106322/article/details/111600758