I have two ArrayList objects with three integers each. I want to find a way to return the common elements of the two lists. Has anybody an idea how I can achiev
ArrayList
Below code Remove common elements in the list
List result = list1.stream().filter(item-> !list2.contains(item)).collect(Collectors.toList());
Retrieve common elements
List result = list1.stream() .distinct() .filter(list::contains) .collect(Collectors.toList());