remove repeated elements in list java code example
Example 1: compare two lists and remove duplicates java
listA.removeAll(new HashSet(listB));
Example 2: remove duplicates from list java
ArrayList<Object> withDuplicateValues;
HashSet<Object> withUniqueValue = new HashSet<>(withDuplicateValues);
withDuplicateValues.clear();
withDuplicateValues.addAll(withUniqueValue);