📜  java查找列表的元素是否存在于另一个列表中 - Java代码示例

📅  最后修改于: 2022-03-11 14:52:44.210000             🧑  作者: Mango

代码示例1
list1.stream()
   .map(Object1::getProperty)
   .anyMatch(
     list2.stream()
       .map(Object2::getProperty)
       .collect(toSet())
       ::contains)

// Example with predicate
Predicate notInList1 = object -> list1.stream().noneMatch(object::equals);
List missingInList1 = list2.stream().filter(notInList1).collect(Collectors.toList());