Java Collection Framework

Collection is a group of seperate objects represented as a single unit and collection framework is an architecture for representing and manipulating the collections.

Collection framework defines several interfaces,d Few of them are :

  • Collection Interface
  • List Interface
  • Set Interface
  • Queue Interface

Map Interface(though not exactly part of framework)

Few of the methods declared in the collection interface and overriden by the child classes

S.NoMethodUsage
1public boolean add(E e), addAll(Collection<? extends E> c)It is used to insert an element in this collection, the other is used to Insert one collection into another.
2public boolean remove(Object element), removeAll(Collection<?> c)used to delete an element, other is used to delete all elements of the collection
3public int size()returns total number of elements in the collection
4public boolean contains(Object element)used to search an element in the collection
5public int size()returns total number of elements in the collection
6public Iterator iterator()returns an iterator
7public boolean isEmpty()check collection for empty
8public int hashCode()returns hashcode of the collection

Iterable Interface

Few of the methods declared in the collection interface and overriden by the child classes

The Iterable interface is the root interface for all the collection classes. The Collection interface extends the Iterable interface and therefore all the subclasses of Collection interface also implement the Iterable interface.

It has only one abstract method:

 Iterator iterator() : 

and returns the iterator over the elements of type T.


Leave a Comment