GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Java Tutorial
  • Advanced Java
  • Interview Questions
  • Exercises
  • Examples
  • Quizzes
  • Projects
  • Cheatsheet
  • DSA in Java
  • Java Collection
  • Collection Interface
  • List Interface
  • Set Interface
  • Queue Interface

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — Java Collection Framework Tutorial - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • Java Tutorial
  • Advanced Java
  • Interview Questions
  • Exercises
  • Examples
  • Quizzes
  • Projects
  • Cheatsheet
  • DSA in Java
  • Java Collection

Java Collection Framework Tutorial

Last Updated : 1 Oct, 2026

Java Collection Framework (JCF) is a set of classes and interfaces that provide ready-made data structures to store and manipulate groups of objects efficiently.

  • Java provides collection interfaces such as List, Set, and Queue, along with the Map interface. These interfaces have ready-made implementations such as ArrayList, HashSet, HashMap, and PriorityQueue, reducing the need to build common data structures from scratch.
  • The Collection Framework improves productivity by making code more reusable, maintainable and faster to develop.

Features of Java Collection Framework

  • Provides ready-to-use data structures (e.g., ArrayList, HashSet, HashMap).9
  • Offers interfaces (Collection, List, Set, Map, Queue) to define standard behaviors.
  • Supports dynamic resizing, unlike arrays with a fixed size.
  • Includes utility methods for operations such as sorting, searching, reversing, and shuffling through the Collections class.
  • Improves code reusability and performance by reducing boilerplate code.

Real World Example

Suppose you are managing a library where thousands of books need to be stored, searched and retrieved. Instead of arranging them manually in different shelves every time, you use a catalog system. Similarly, the Java Collection Framework acts as a catalog that organizes and manages objects efficiently.

Example

Java Program to illustrate the use of ArrayList (dynamic array) in the Collection Framework

Java
import java.util.*;  
public class Geeks {
    public static void main(String[] args) {
        
        // Creating a List of Strings using ArrayList (dynamic array)
        List<String> list = new ArrayList<>();
        
        // Adding elements to the ArrayList
        list.add("Java");
        list.add("Python");
        list.add("C++");

        // Printing the elements of the ArrayList
        System.out.println("Programming Languages:");
        
        // Enhanced for-loop to iterate through the list
        for (String lang : list) {
            System.out.println(lang);
        }
    }
}

Output
Programming Languages:
Java
Python
C++

Core Interfaces

The Java Collections Framework includes the Collection hierarchy with interfaces such as List, Set, Queue, and Deque, along with the separate Map hierarchy for storing key-value pairs.

  • Collection Interface
  • List Interface
  • Set Interface
  • Queue Interface
  • Deque Interface
  • Map Interface

List Implementations

Lists represent ordered collections that allow duplicate elements and positional access. They include dynamic arrays, linked structures and legacy classes designed for sequential storage.

  • ArrayList
  • LinkedList
  • Vector
  • Stack
  • AbstractList
  • AbstractSequentialList

Set Implementations

Sets represent collections of unique elements, disallowing duplicates. They provide implementations with different ordering strategies like hashing, insertion order or sorting.

  • HashSet
  • Linked HashSet
  • TreeSet
  • EnumSet
  • SortedSet Interface
  • NavigableSet
  • ConcurrentSkipListSet

Queue / Deque Implementations

Queues store elements in a FIFO manner, while Deques allow operations at both ends. They are used for scheduling, buffering and producer-consumer applications.

  • Priority Queue
  • Array Deque
  • ConcurrentLinked Queue

Map Implementations

Maps store data as key-value pairs where keys are unique. Different implementations provide hashing, ordering, reference-based and concurrent behaviors.

  • HashMap
  • LinkedHashMap
  • TreeMap
  • WeakHashMap
  • IdentityHashMap
  • HashTable

Utility and Supporting Classes

Java provides helper classes and interfaces to enhance collection usage. They include Collections, Iterator, Comparator and other tools for iteration and sorting.

  • Collections Class
  • Iterable interface
  • ListIterator
  • Enumeration
  • Comparator
  • Comparable

Concurrency Collections

Concurrent collections are designed for multi-threaded environments. They ensure thread-safe access without compromising performance.

  • ConcurrentHashMap
  • CopyOnWriteArrayList
  • ConcurrentLinkedQueue
  • BlockingQueue (ArrayBlockingQueue, LinkedBlockingQueue )
Comment

Explore

    Basics
    • Introduction3 min read
    • Variables2 min read
    • Data Types7 min read
    • Operators7 min read
    • Decision Making5 min read
    • Methods7 min read
    • Arrays7 min read
    • Strings5 min read
    OOP & Interface
    • Introduction6 min read
    • Constructors6 min read
    • Encapsulation3 min read
    • Inheritance8 min read
    • Polymorphism5 min read
    • Abstraction5 min read
    • Interfaces8 min read
    Collections
    • Collection class9 min read
    • Collection Interface5 min read
    • List Interface8 min read
    • Set Interface5 min read
    • Queue Interface5 min read
    • Map Interface in Java6 min read
    • Iterator4 min read
    Advance Java Concepts
    • Exception handling6 min read
    • Java Multithreading Tutorial3 min read
    • Synchronization in Java9 min read
    • File handling6 min read
    • Method References3 min read
    • Java 8 Stream Tutorial7 min read
    • Memory Management4 min read
    • Garbage Collection in Java6 min read
    • Networking6 min read
    • JDBC5 min read
    Practice Java
    • Interview Questions15+ min read
    • Programs6 min read
    • Practice Problems5 min read
    • Quiz1 min read
    • Project Ideas15+ min read
    Courses
    • Java Backend Course2 min read
    • Placement 360 Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.