java util AbstractCollection Class
AbstractCollection Class in Java
The AbstractCollection class provides a skeletal implementation of the Collection interface. To implement an unmodifiable collection, the programmer needs only to extend AbstractCollection 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 AbstractCollection class's add method (which otherwise throws an UnsupportedOperationException), and the iterator returned by the iterator method must additionally implement its remove method.
The programmer should generally provide a void (no argument) and Collection constructor, as per the recommendation in the Collection interface specification.
java.util.AbstractCollection class Example