Collections in Java Part I : Introduction.

Hello Friends,

This is one of my tutorials regarding one of the best feature in java i.e. Collections Framework. First of all, we need to understand the basic characteristics regarding this.

Why Collections?

In the versions prior to 1.2 the standard methods for grouping Java objects were via the Array, the Vector, and the HashTable classes, which were not easy to extend, and did not implement a standard member interface.

Collections:  Introduction.

A collection, in general, means something like a group of objects stored in a structured manner, it is also called as a container. The Java collections framework is a set of classes and interfaces that implements commonly reusable collection data structures. It represents a group of objects, known as its elements. Basically it is a package of commonly used data structures that includes Lists, Sets and Maps.

However the interfaces Map and Collection are distinct, they are the two top-level interfaces. They both are at the same level in hierarchy, it can be viewed as:-

The reason for this distinction has to do with the ways that Set and Map are used in Java. Sets cannot contain duplicates and provide random access to their elements; Maps connect unique keys with values, provide random access to its keys and may host duplicate values.

The Collections Framework provides a well-designed set of interfaces and classes for storing and manipulating groups of data as a single unit, a collection.

While using this Framework remember the following hierarchical relationships of the four basic interfaces of the collections-

  • The Collection interface is a group of objects, which also allows duplicates.
  • Set extends Collection but does not allow duplicates.
  • List extends Collection, allows duplicates and introduces positional indexing.
  • Map neither extends Set nor Collection.

The three collection interfaces can be implemented in six ways, each twice, as follows

Advantage of the Collections Framework:

The collections framework offers following advantages for the java developers:

  • Increases the readability of collections by providing a standard set of interfaces which has to be used by developers in different applications.
  • It makes the code more flexible
  • It offers many specific implementations of the interfaces.
  • It allows you to choose the collection that is most fitting and which offers the highest performance for your purposes.

These collections framework are very easy to implement. These interfaces can be transparently substituted to increase the application performance.

Hope this will help you.


One thought on “Collections in Java Part I : Introduction.”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.