Question: I am trying to make a basic custom iterator within a class that simply iterates through an array but I'm having significant trouble. With what
I am trying to make a basic custom iterator within a class that simply iterates through an array but I'm having significant trouble. With what I have, my biggest trouble is the next() method; the compiler thinks the E generic is different from MyArrayList
public Iterator
public boolean hasNext(){ return indexPosition < size; } public E next(){ E e = list[indexPosition];// wrong ++indexPosition; return e; }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
