Introduction To Collection Framework

In my last post I have written the concept of But in this post I am trying to provide an introduction to Collection framework, that solves the problem of array.

Advantages of collection:
  • It is grow able in nature, based on programmer or application need , this can be increased or decreased.
  • It can hold homogeneous or heterogeneous data
  • Every collection is backed by some data structure [ready made data structure]

To overcome problem of array it is important to use collection.

Collection:  Collection is way of representation of a group of objects as a single entity.In general collection interface is considered as root interface of collection framework.

Collection Framework: It is group of several classes and interfaces which can be used to represent a group of objects a single entity.

In C++ collection is called container but in java it is called Collection
The group is called STL[standard Template Library] but in java it is called collection framework.

key elements of Collection framework are:
There is no concrete class which implements collection interface directly.

The list of methods present in collection interface are:
  • boolean add(Object o)
  • boolean addAll(Collection c)
  • boolean remove(Object o)
  • boolean removeAll(Collection c)
  • boolean retainAll(Collection c)--remove all objects except those present in collection c
  • void clear()
  • boolean contains(Object o)
  • boolean containAll(Collection c)
  • boolean isEmpty()
  • int size()
  • Object[] to Array()
  • Iterator iterator()

Collection is an interface which can be used to represent a group of objects as  a single entity.
Collections is an utility class found in java.util package to define several utility methods for collection objects.
    Introduction To Collection Framework Introduction To Collection Framework Reviewed by Animesh Chatterjee on July 14, 2013 Rating: 5


    1. where we use collections framework in real time in industry............please tell bro?

    2. Hi Muzammil,
      Collection framework comes handy when you don't know upfront how much data element to handle.
      Please go through this link....It has clearly explained the need of collection


    Powered by Blogger.