Primary Menu

Complete Collection Framework in Java with Programming Example

In this chapter you will learn:

What is Collection in Java?

Java Collection Structure

List Interface

Queue Interface

Set Interface

Map Interface

What is Collection in Java?

Before starting this tutorial you must need to know what Collection in Java is and how to use it in programming. You also need to know the benefit of collection. A collection is like an array which stores collection of data but there is huge difference between them. An array size is fixed and it is defined while initialized array but the size of collection objects is dynamic and can be grow or shrink at run time. There is also various usage of Collection object that is mentioned below:

Collection support more flexible data structure than array.

The complexity of Collection framework is encapsulated and you are provided several methods and properties to work with them. For example for adding any new element there is add() method. So, it simplifies your code and gives better access to collection element than array.

It reduces your development effort by providing rich set of classes.

It gives you robust code quality because it is tested by several high qualified programmers.

Structure of Collection

You will learn all the classes and interfaces of collections in next few chapters. All the classes are explained with complete programming examples.

A Queue is based on First in First Out formulae. This collection is designed for holding elements prior to processing. Apart from basic collection operations it provides additional insertion, extraction and inspection operations.

Iterator and ListIterator both are used for traversing collections still there are some differences between Iterator and ListIterator. Iterator and listiterator is very useful and we will use it widely in collection programming.

Summary

It is only overview of collections framework. We have kept this topic short and useful but all the interfaces are explained in details in separate chapter. So, let’s start with List Interface