Java Collections Framework Simple

In this Post you will get details about Java’s Core Collection interfaces and more details about Java Core collections.

Collection is an Object which holds data items that form a natural group. Example:- Collection of Names, collection of letters in mail etc…

Java defines some Core Collections which we can use based on the requirement like type of data and many other factors like uniqueness, name-value pair, order and Time taken to do CURD operations.

In Java Collection is the top level interface. All the Collections interfaces (Except Map) extends this Top level Collection .

Below are the Collection interfaces which Extends To Top Level Collection interface

  • Set
  • List
  • Queue
  • DeQueue
  • Map (doesn’t extend Collection interface)

Set Interface

Set is a special Type of Collection Interface which stores Unique items. so When we have a requirement where we don’t want to store duplicate elements then Set can be used to store elements. For Example:- storing the IDs of users created in a website.
Below are the implementations of the Set Interface in Java

  • HashSet
  • TreeSet
  • LinkedHashSet

List Interface

List is a Type of Collection Interface which can store Duplicate items. List is also known as Ordered Collections. Using List one can retrieve elements using Position of the element in the list

Below are the implementations of the List Interface in Java

  • ArrayList
  • LinkedList

Queue Interface

Queue is a Collection for holding elements prior to processing. Queues provide additional insertion, removal, and inspection operations. Queue Typically follows element in FIFO order

DeQueue Interface

Dequeue are similar to Queue, except they can be accessed from both ends. DeQueue are known as double-ended-queue.

Map Interface

Map Interface is a special kind of Collection which doen’t extend Collection interface like other Core Collections. Map Interface is used to store Key Value pairs unlike other collection interfaces. A map cannot contain duplicate keys

Below are the implementations of the Map Interface in Java

  • HashMap
  • TreeMap
  • LinkedHashMap

We will find More details about Collections and their implementations in Next Topics