loop through and clear a bunch of arraylists java code example
Example 1: remove arraylist index in for loop
for (int i = data.size()-1; i >= 0; i--){
if (data.get(i).contains(element)){
data.remove(i);
}
}
Example 2: java remove from arraylist while iterating
ListIterator<Book> iter = books.listIterator();
while(iter.hasNext()){
if(iter.next().getIsbn().equals(isbn)){
iter.remove();
}
}