Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » » 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.

    «
    Next
    Newer Post
    »
    Previous
    Older Post

    2 comments:

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

      ReplyDelete
    2. Hi Muzammil,
      Collection framework comes handy when you don't know upfront how much data element to handle.
      Please go through http://stackoverflow.com/questions/2497134/what-is-the-need-of-collection-framework-in-java this link....It has clearly explained the need of collection

      ReplyDelete