List<User> userList= new ArrayList<>(); List<User> userMergeList= new ArrayList<>(); userList.parallelStream().collect(Collectors.groupingBy(o -> (o.getUserId() + o.getUserName()), Collectors.toList())).forEach((id, transfer) -> { transfer.stream().reduce((a, b) -> new User(a,b)).ifPresent(userMergeList::add); }); public User(User user1, User user2){ this.userName = user1.userName(); this.score = user1.getScore().add(user2.getScore()); }
标签:user2,user1,getScore,List,User,集合,new,属性 From: https://www.cnblogs.com/yxl-wyb/p/17282070.html