I have two lists filled with object elements. Using these two lists, I want to create another list which contains only the uncommon elements between them.
I tried using an iterator:
for(Row currentRowObject: currentRow) {
for (Iterator<Row> newError = newErrorRow.iterator(); newError.hasNext(); ) {
Row rowObject = newError.next();
if (rowObject.getAll().equals(currentRowObject.getAll())) {
newError.remove();
}
}
}
After I run this, the newError
list is completely removed. I checked that the two lists are different, they differ in size and there are objects that differ between these two lists.
How can I solve this problem?