0
How to make arraylist only access original values not duplicates
To Make arraylist like as. HashSet?? code is needed
1 Réponse
+ 1
The easiest way to remove repeated elements is to add the contents to a Set (which will not allow duplicates) and then add the Set back to the ArrayList:
List<String> al = new ArrayList<>();
Set<String> hs = new HashSet<>();
hs.addAll(al);
al.clear();
al.addAll(hs);