ArrayList<Object> withDuplicateValues; HashSet<Object> withUniqueValue = new HashSet<>(withDuplicateValues); withDuplicateValues.clear(); withDuplicateValues.addAll(withUniqueValue);