public Map test(){
List<String> userInfoIdsPrevious = Arrays.asList("1","2", "3");//少的
List<String> userInfoIds = Arrays.asList("1", "2","4");//多的
//添加的id
List<String> change1 = userInfoIds.stream().filter(u -> {
return !userInfoIdsPrevious.contains(u);
}).collect(Collectors.toList());
//删除的id
List<String> change2 = userInfoIdsPrevious.stream().filter(u -> {
return !userInfoIds.contains(u);
}).collect(Collectors.toList());
Map<String, Object> map = new HashMap<>();
map.put("添加的",change1);
map.put("删除的",change2);
return map;
}
转载于:https://my.oschina.net/zhangshsURL/blog/1581904