📅  最后修改于: 2022-03-11 14:52:06.138000             🧑  作者: Mango
Set result = list.stream() .distinct() .filter(otherList::contains) .collect(Collectors.toSet()); Set commonElements = new HashSet(Arrays.asList("red", "green")); Assert.assertEquals(commonElements, result);