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!!
You’re defining a single constructor for your iterator,
MyIterator(MyListNode<E> start). From your code, it’s clear that theMyListNode<E> startargument is missing.What I mean is, in this line:
… you need to pass a reference to the first node in the list, something like this: