Hello everybody, this is my first post
here. I want to code an iterator for a
data structure homework. The instructor told
us that Iterator has to be a sperarate class.
Let's assume we have a doubly linkd list with nodes.

in main
Code:
iterator i = l.iterator();
(l is the name of the list)

then we use
Code:
for ( ; i.hasNext(); )
 System.out.preintln(i.next());
Now in order to this work shouldnt
iterator be in the list class? How is the iterator
will get the position of the list without being in the
list? We are not passing any parameters to
the iterator. How do we keep track of
the data? The intructor told us that iterator should be
a speratae class and it has to have a List and
a node inside. I am very confused. i know this is
a very easy problem but I can't figure that out.

Thanks in advance..

[ArchAngel added CODE tags]