Hello I have an array of objects. but these objects end up repeating themselves, so I wanted a naneira to remove the duplicates.
I've tried using hasSet, but it does not seem to work with objects.
Set nova = new HashSet<>();
nova.addAll(Objetos);
Objetos.clear();
Objetos.addAll(nova);
I've tried to use a comparison if but it did not work out either.
List<T> naoDuplicado = new ArrayList<T>();
for (T obj : naoDuplicado) {
if (!naoDuplicado.contains(Obj)) {
naoDuplicado.add(element);
}
}