Java

Collections Framework

33 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.

  1. 1.Collections Overview

    The Java Collections Framework (JCF) is a unified architecture for representing and manipulating groups of objects.

  2. 2.Iterable

    Iterable<E> is the root interface of the Java Collections hierarchy.

  3. 3.Collection Interface

    Collection<E> is the root interface of the main collection hierarchy, extending Iterable<E>.

  4. 4.ArrayList

    ArrayList is a resizable-array implementation of the List interface.

  5. 5.LinkedList

    LinkedList is a doubly-linked list implementation of both the List and Deque interfaces.

  6. 6.Vector

    Vector is a legacy resizable-array implementation of the List interface that predates the Collections Framework.

  7. 7.Stack

    Stack is a legacy class that extends Vector and represents a last-in, first-out (LIFO) stack of objects.

  8. 8.Queue Interface

    The Queue interface in java.util represents a collection designed for holding elements prior to processing, following a defined ordering policy.

  9. 9.PriorityQueue

    PriorityQueue is an unbounded queue implementation backed by a binary heap that orders elements by priority rather than insertion order.

  10. 10.Deque

    Deque (pronounced 'deck') stands for double-ended queue — a linear collection that supports element insertion and removal at both ends.

  11. 11.ArrayDeque

    ArrayDeque is the recommended general-purpose Deque implementation in Java.

  12. 12.HashSet

    HashSet is the most commonly used Set implementation in Java.

  13. 13.LinkedHashSet

    LinkedHashSet is a Set implementation that combines the O(1) performance of a hash table with the predictable iteration order of a doubly-linked list.

  14. 14.TreeSet

    TreeSet is a NavigableSet implementation backed by a red-black tree that stores elements in sorted order.

  15. 15.SortedSet

    SortedSet is an interface that extends Set and adds the contract that all elements are maintained in ascending order, determined either by their natural ordering…

  16. 16.NavigableSet

    NavigableSet extends SortedSet with a rich set of navigation methods that go beyond the simple range-view operations of SortedSet.

  17. 17.HashMap

    HashMap is the most widely used Map implementation in Java.

  18. 18.LinkedHashMap

    LinkedHashMap extends HashMap and maintains a doubly-linked list running through all its entries, preserving the order in which entries were inserted.

  19. 19.TreeMap

    TreeMap is a Red-Black tree implementation of the NavigableMap interface.

  20. 20.Hashtable

    Hashtable is a legacy hash table implementation that predates the Collections Framework.

  21. 21.ConcurrentHashMap

    ConcurrentHashMap is a thread-safe, high-performance hash map optimised for concurrent access.

  22. 22.WeakHashMap

    WeakHashMap is a hash map implementation where the keys are held with weak references.

  23. 23.IdentityHashMap

    IdentityHashMap is a Map implementation that uses reference equality (==) instead of object equality (equals()) to compare keys.

  24. 24.EnumMap

    EnumMap is a specialised Map implementation for use with enum keys.

  25. 25.Collections Class

    The Collections class in java.util is a utility class consisting entirely of static methods that operate on or return collections.

  26. 26.Comparable

    Comparable is a functional interface in java.lang that defines a natural ordering for a class.

  27. 27.Comparator

    Comparator is a functional interface in java.util that defines an ordering for objects that is separate from the objects themselves.

  28. 28.Iterator

    Iterator is the fundamental traversal interface in the Java Collections Framework.

  29. 29.ListIterator

    ListIterator extends Iterator to provide bidirectional traversal of List elements, along with the ability to add, set, and remove elements during iteration.

  30. 30.Spliterator

    Spliterator (Splittable Iterator) is Java 8's mechanism for parallel and sequential element traversal of sources such as collections, arrays, I/O channels, and…

  31. 31.Fail-Fast vs Fail-Safe

    Fail-fast and fail-safe are two competing philosophies for how Java iterators and collections respond to structural modifications made to a collection while it is being…

  32. 32.Immutable Collections

    Immutable collections in Java are collections that cannot be structurally modified after creation — no elements can be added, removed, or replaced.

  33. 33.Synchronized Collections

    Synchronized collections wrap standard Java collections to make every individual method call thread-safe via an intrinsic monitor lock.