1. Collection Interface (Root Interface)
The Collection<E> interface is the root of the framework, but it doesn’t have direct implementations. Instead, it has three key subinterfaces:
A. List Interface (List<E>) – Ordered, allows duplicates
| Implementation | Description |
|---|
ArrayList<E> | Resizable array (fast random access, slower insertions/removals) |
LinkedList<E> | Doubly linked list (fast insertions/removals, slow random access) |
Vector<E> | Synchronized version of ArrayList (rarely used today) |
Stack<E> | LIFO stack (extends Vector) |
B. Set Interface (Set<E>) – No duplicates, unordered
| Implementation | Description |
|---|
HashSet<E> | Uses a HashMap internally (fast, no order) |
LinkedHashSet<E> | Preserves insertion order (slightly slower than HashSet) |
TreeSet<E> | Stores elements in sorted order (implemented using TreeMap) |
C. Queue Interface (Queue<E>) – Follows FIFO (First-In-First-Out)
| Implementation | Description |
|---|
PriorityQueue<E> | Elements are ordered based on natural ordering or a comparator |
LinkedList<E> | Can be used as a queue (FIFO) or a deque (double-ended queue) |
Specialized Queue:
| Interface | Implementation | Description |
|---|
| Deque<E> (Double-ended queue) | ArrayDeque<E> | More efficient than Stack, allows adding/removing from both ends |
2. Map Interface (Map<K, V>) – Key-Value pairs, No duplicate keys
| Implementation | Description |
|---|
HashMap<K, V> | Fast access, unordered keys (most commonly used Map) |
LinkedHashMap<K, V> | Maintains insertion order |
TreeMap<K, V> | Stores keys in sorted order |
Hashtable<K, V> | Thread-safe version of HashMap (rarely used today) |
ConcurrentHashMap<K, V> | Thread-safe, high-performance alternative to Hashtable |
Hierarchy Summary
Collection (interface)
├── List<E>
│ ├── ArrayList<E>
│ ├── LinkedList<E>
│ ├── Vector<E>
│ ├── Stack<E>
│
├── Set<E>
│ ├── HashSet<E>
│ ├── LinkedHashSet<E>
│ ├── TreeSet<E>
│
├── Queue<E>
│ ├── PriorityQueue<E>
│ ├── LinkedList<E> (Queue)
│
├── Deque<E>
├── ArrayDeque<E>
Map<K, V> (interface)
├── HashMap<K, V>
├── LinkedHashMap<K, V>
├── TreeMap<K, V>
├── Hashtable<K, V>
├── ConcurrentHashMap<K, V>
Key Takeaways
Collection interface is the root interface of List, Set, and Queue.Map is NOT a Collection, but is part of the Java Collections Framework.- Use Cases:
ArrayList → Fast random access, dynamic size.LinkedList → Fast insertions/removals, slow access.HashSet → Unique elements, fast operations.TreeSet → Sorted elements.HashMap → Fast key-value lookups.