java - CustomLinkedList with generics -
i implementing linkedlist generics. i'm getting "multiple markers @ line - type myiterator not generic; cannot parameterized arguments " @ return statement. figure interface
public iterator<figure> iterator() { class myiterator implements iterator<figure> { private node current; private myiterator(node n) { current = n; } public boolean hasnext() { return current.next != null; } public figure next() throws nosuchelementexception { if (current.next == null) throw new nosuchelementexception(); current.setnext(current.next); object c=current; return (figure) c; } public void remove() { throw new unsupportedoperationexception(); } } return new myiterator<figure>(); }
clearly myiterator
not generic. you've use generic type. change return statement to:
return new myiterator();
Comments
Post a Comment