How can I implement a collection using a linked list by extending the Abstract collection? I'd have to use the void remove method if Iterator, and implement this and the add and size methods.
1 Answer 1
See the Java doc for AbstractCollection for more details:
To implement an unmodifiable collection, the programmer needs only to extend this class and provide implementations for the iterator and size methods. (The iterator returned by the iterator method must implement hasNext and next.)
To implement a modifiable collection, the programmer must additionally override this class's add method (which otherwise throws an UnsupportedOperationException), and the iterator returned by the iterator method must additionally implement its remove method.
public abstract int size()
public abstract Iterator<E> iterator()
Iterator defines this methods:
boolean hasNext()
E next()
void remove()