I was browsing over the following code example:
public class GenericTest {
public static void main (String[] args) {
ArrayList myList = ne
An iterator is an abstraction over how a collection is implemented. It lets you go over the whole collection one item at a time, optionally removing items.
The disadvantage of an Iterator is that it can be a lot slow if you DO know the underlying implementation. For example using an Iterator for an ArrayList is considerable slower than just calling ArrayList.get(i) for each element. Whether this matters much depends on what the code is doing.