Header Ads

Introduction To Collection Framework

In my last post I have written the concept of array..here. 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.
    Powered by Blogger.