Collection interface methods:
Collection method | Description |
boolean add(Object obj); | add/inserts a single element/object to invoking collection |
boolean addAll(Collection c); | add/inserts group of element/objects to invoking collection
(i.e.; adding specified collection to invoking collection)
|
boolean remove(Object obj); | remove/deletes a single element/object from invoking collection |
boolean removeAll(Collection c); | remove/deletes group of element/objects to the invoking collection
(i.e.; removing specified collection from invoking collection)
|
boolean retainAll(Collection c); | remove/deletes all element/objects of invoking collection except specified collection
(i.e.; retaining specified collection and removing other objects from invoking collection)
|
void clear(); | remove/deletes all element/objects from invoking collection |
boolean contains(Object obj); | used to search specified object from invoking collection
returns true, if present; otherwise return false
|
boolean containsAll(Collection c); | used to search specified collection from invoking collection
returns true, if present; otherwise return false
|
boolean isEmpty(); | checks whether invoking collection is empty or NOT
returns true, if empty; otherwise return false
|
int size(); | returns number of element/objects present in the invoking collection (at the time of invoking) |
Object toArray(); | converts invoking collection into array
returns object array
|
Iterator iterator(); | returns iterator for the invoking collection; to iterate over the collection elements in FORWARD direction only |
boolean equals(Object element); | compares specified object with invoking collection for equality |
int hashCode(); | returns hash code for invoking collection |