慕码人2483693
List> list1 = new ArrayList<>();
List> list2 = new ArrayList<>();
list1.stream()
.filter(map -> list2.stream().anyMatch(map1 -> map.get("id").equals(map1.get("id"))))
.forEach(map -> {
// to do sth
});
你试试这个呢
List> list3 = list1.stream()
.map(map -> list2.stream()
.filter(m -> Objects.equals(m.get("id"), map.get("id")))
.findFirst().map(m -> {
map.putAll(m);
return map;
}).orElse(null))
.filter(Objects::nonNull).collect(Collectors.toList());