Reputation: 301
I get an error when I try return new MyIterator() and I'm not sure what to do with the MyIterator constructor (have to define iterator based on a start node parameter). Any idea how to fix this? I know how to implement the next and hasNext.
I think I solved it....Thanks!!
Upvotes: 1
Views: 1538
Reputation: 236004
You're defining a single constructor for your iterator, MyIterator(MyListNode<E> start)
. From your code, it's clear that the MyListNode<E> start
argument is missing.
What I mean is, in this line:
return new MyIterator();
... you need to pass a reference to the first node in the list, something like this:
return new MyIterator(firstNode); // replace firstNode with the actual value
Upvotes: 2