You can use b.remove(i) to remove entries. Loop down from the end of the list to the beginning to avoid confusing your loop's indexing when you delete an entry
You can't use any ordinary iterator because they don't allow you to change the List while iterating.
a ListIterator allows you to update & delete while iterating. You get one simply by b.listIterator() then use it as described in the API doc.