Tutorials

Java Collection Framework


Introduction to Collection


Java Collections Framework(JCF) becomes valuable because of the collection of interfaces and classes that it has to offer to the java programmer.  Using JCF gives programmer a smooth and efficient way of storing, retrieving and manipulating the data.

 

To understand this framework, you first need to understand the framework hierarchy. And for that let's take  a look at the below diagram:

 

Collection Hierarchy in java

 

What we see from above diagram?

 

There is a collection interface at the top and is the root of the collection hierarchy. And then we have sub-interfaces like Set, List, Queue, Deque, etc. 

Java platform doesn’t provide direct implementation for this root interface rather it provides implementation for more specific sub-interfaces like List, Set, etc.

 

Now we will go through each of the sub-interfaces one by one. 

 

List

  1. ArrayList
  2. LinkedList
  3. Vector

Set

  1. HashSet
  2. LinkedHashSet
  3. TreeSet

Map

  1. HashMap
  2. LinkedHashMap
  3. TreeMap

Benefit of Collection Framework

  • Collection  enhances code reusability and inter-operability between unrelated API's
  • Collection provides lots of in-built methods which increases speed of the development process.
  • Programmers can rest assured while using Collection as the framework is already well tested and maintained.
  • Collection also provides concept of Generics which helps to restrict the type of Object that your collection can store. In case other data type is stored compile time error will occur.

 



Please Share this page
Views : 130