1
I need help creating a logic that checks whether certain attributes of an object, stored in a List<Object>
, there are more than two times.
I’ve tried using the Set<E>
to check whether it is possible to store the data, as repeated information is not allowed on it. However, the ID I need to check is repeated, repeats in a non-linear order. My code for the attempt is as follows:
public List<Object> processaListaAuxiliar(List<Object> listaDrem) {
List<Object> listaAux = new ArrayList<Object>();
Set<Object> hashSet = new HashSet<Object>();
for (Object obj : listaDrem) {
if(obj instanceof LinhaExcel) {
if(!hashSet.add(((LinhaExcel) obj).getUgEmitente())) {
System.out.println("-----");
} else {
System.out.println("TESTE");
}
}
}
return listaAux;
}
You need to know which ones are duplicated or simply not show more duplicates?
– Sorack
I need to know which ones are duplicated
– jotape