I have a method which iterates through a list and removes an object.
public void iterateAndRemove(List<String> l) {
for (String s : l) {
l.remove(s); //should throw exception
}
}
Ideally, this should throw an exception as I am not using Iterator
.
But it just works fine. Is my understanding wrong?