I just learned about how the Java Collections Framework implements data structures in linked lists. From what I understand, Iterators are a way of traversing th
Why is this interface used?
Because it supports the basic operations that would allow a client programmer to iterate over any kind of collection (note: not necessarily a Collection in the Object sense).
Why are the methods... not directly coded to the data structure implementation itself?
They are, they're just marked Private so you can't reach into them and muck with them. More specifically:
Iterator such that it does something the standard ones don't do, without having to alter the actual object it iterates over.Iterators to however many clients you wish, and each client may traverse in their own time, at their own speed.Iterators from the java.util package in particular will throw an exception if the storage that backs them is modified while you still have an Iterator out. This exception lets you know that the Iterator may now be returning invalid objects.For simple programs, none of this probably seems worthwhile. The kind of complexity that makes them useful will come up on you quickly, though.