for(int i = 0; i < list1.size() - 1; i++){ if(list1.get(i).compareTo(list2.get(i)) == 0){ list1.remove(list2.get(i)); } }
once an element is removed from either list their sizes will be different from the other. So you can't compare the remaining elements of a list with the others original position
You could use a nested loop to check if a value from a list is present with every element from the other