Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
How to make arraylist only access original values not duplicates
To Make arraylist like as. HashSet?? code is needed
1 Resposta
+ 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);