📜  java 8 将对象中的所有列表检索到单个列表中并忽略重复项 - Java 代码示例

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

代码示例1
public void
  givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
    List listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3);
    List listWithoutDuplicates = listWithDuplicates.stream()
     .distinct()
     .collect(Collectors.toList());
}