Java8排重

List<CfUserContactDO> userContacts = new ArrayList<>();
...
//(oldValue, newValue) -> oldValue)
Map<Long, CfUserContactDO> dataMap = userContacts.stream().collect(Collectors.toMap(user -> user.getId(),
                                                                                    user -> user,
                                                                                    (user1, user2) -> user1));

 

posted @ 2020-03-10 12:28  人生如若初见  阅读(379)  评论(0编辑  收藏  举报