Iterator
is a generic interface, but your ListIterator
is neither generic nor parameterizes Iterator
. Start by making ListIterator
implement Iterator<Type>
:
private class ListIterator implements Iterator<Type> {
// the rest should be fine
}
or making ListIterator
generic as well (more complicated):
private class ListIterator<T> implements Iterator<T>
{
private int curPos, expectedCount;
private Node<T> itNode;
private ListIterator()
{
curPos = 0;
expectedCount = modCount;
itNode = sentinel;
}
public boolean hasNext()
{
return (curPos < expectedCount);
}
public T next()
{
// snip
}
}