📜  获取两个列表的交集java代码示例

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

代码示例1
Set result = list.stream()  .distinct()  .filter(otherList::contains)  .collect(Collectors.toSet()); Set commonElements = new HashSet(Arrays.asList("red", "green")); Assert.assertEquals(commonElements, result);