Java Collections

Complete Collection Framework in Java with Programming Example

Java CollectionsIn this chapter you will learn:

  1. What is Collection in Java?
  2. Java Collection Structure
  3. List Interface
  4. Queue Interface
  5. Set Interface
  6. 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:

  1. Collection support more flexible data structure than array.
  2. 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.
  3. It reduces your development effort by providing rich set of classes.
  4. It gives you robust code quality because it is tested by several high qualified programmers.

Structure of Collection

Java Collections

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

List Interface

A list is an order collections or sequence of items. You can insert, delete or search items based on index position. It also allows duplicate entry in the list collections.

1. ArrayList
2. LinkedList
3. Vector
4. Stack

Queue Interface

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.

1. PriorityQueue
2. Deque
3. ArrayDeque

Set Interface

Unlike List Interface Set doesn’t allow adding duplicate values in collection. It contains method only inherited from collections and prohibited duplicate entries.

1. HashSet
2. LinkedHashSet
3. SortedSet
4. TreeSet

Map Interface

A Map is an object that maps keys to values. It contains unique keys for all the elements and that elements can be accessed later using keys value. A map cannot contain duplicate keys.

1. Hashtable
2. LinkedHashMap
3. HashMap
4. TreeMap

Iterator and ListIterator

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.


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

Leave a Reply

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