I'm unsure how to add Iterator code to my DLL class
i tried two approaches but i get compile errors in both cases:
public static void main(String[] args)
{
DLL myList = new DLL() ;
...
public java.util.Iterator iterator()
(
return new LRIterator() ;
)
private class LRIterator implements Iterator
{
...
}
...
compile error: ';' expected public java.util.Iterator iterator();
other approach:
public static void main(String[] args)
{
DLL myList = new DLL() ;
...
Iterator itr = myList.iterator();
while(itr.hasNext()) {
Object element = itr.next();
System.out.print(element + " ");
}
...
copile error: cannot find symbol Iterator = myList.iterator();