java 8 find duplicates in list of objects code example
Example: java 8 retrieve all list from object into single list and ignore duplicates
public void
givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
List<Integer> listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3);
List<Integer> listWithoutDuplicates = listWithDuplicates.stream()
.distinct()
.collect(Collectors.toList());
}