java 8 retrieve all list from object into single list and ignore duplicates

Solutions on MaxInterview for java 8 retrieve all list from object into single list and ignore duplicates by the best coders in the world

showing results for - "java 8 retrieve all list from object into single list and ignore duplicates"
Yannick
09 Jul 2016
1public void
2  givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
3    List<Integer> listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3);
4    List<Integer> listWithoutDuplicates = listWithDuplicates.stream()
5     .distinct()
6     .collect(Collectors.toList());
7}
8