Java Collections Framework Hierarchy Explained
Fast recall
Quick revision
Core answer
ArrayList, HashSet, and HashMap implement these interfaces.Whether you can draw the framework's backbone from memory and correctly place Map outside the Collection branch
Drawing Map as a child of Collection, or forgetting Queue is a third branch alongside List and Set
Explain that the for-each loop works because Iterable sits at the root, and that Map bridges back via keySet/values/entrySet views
Interview-ready guide
Interview answer
The Java Collections Framework is a set of interfaces and classes for storing groups of objects, and it sits on a clean tree.
At the very top is Iterable — that's the simplest interface, it just gives you an iterator so you can loop over things with a for-each. Collection extends Iterable and adds the core operations like add, remove, size, and contains. From Collection you get three branches.
The first is List, which keeps elements in order and allows duplicates — that's ArrayList and LinkedList. The second is Set, which doesn't allow duplicates — that's HashSet and TreeSet. The third is Queue, for elements you process in sequence — like LinkedList or PriorityQueue.
Now the part interviewers love to test: Map is completely separate. It does not extend Collection. The reason is that Map stores key-value pairs, and its methods like put and get take two arguments, which simply don't fit Collection's single-element contract built around add.
If Map were forced under Collection, the API would be confusing. Map does give you a bridge, though — you can call keySet to get the keys as a Set, values to get the values as a Collection, and entrySet to get the pairs. So the mental picture is: Iterable at the top, then Collection splitting into List, Set, and Queue, with Map standing on its own beside them.
The classic mistake is saying Map extends Collection — it's a sibling, not a child.
Java Collections Framework Hierarchy Explained
Direct Answer
Iterable is the root interface; Collection extends it and branches into List, Set, and Queue. Map is a separate hierarchy — it does NOT extend Collection because it stores key-value pairs, not single elements. Concrete classes like ArrayList, HashSet, and HashMap implement these interfaces.
Code Example
import java.util.*;
public class HierarchyDemo {
public static void main(String[] args) {
// Iterable: the root - anything you can loop over
Iterable<String> iterable = List.of("A", "B");
// Collection extends Iterable: add/remove/size/contains
Collection<String> col = new ArrayList<>();
col.add("order-1");
// List branch: ordered, indexed, duplicates allowed
List<String> list = new ArrayList<>(col);
String first = list.get(0); // positional access
// Set branch: rejects duplicates
Set<String> set = new HashSet<>(list);
// Queue branch: FIFO processing
Queue<String> queue = new LinkedList<>();
queue.offer("task-1");
// Map: SEPARATE hierarchy - key/value, not under Collection
Map<String, Integer> prices = new HashMap<>();
prices.put("order-1", 100);
// Map bridges back via Collection views
Set<String> keys = prices.keySet();
Collection<Integer> vals = prices.values();
}
}
Common Mistakes & Pitfalls
- Saying Map extends Collection. This is the single most-tested misconception. Map is a sibling hierarchy, not a child — its
put(key, value)cannot fitCollection.add(element). - Forgetting Queue. Many freshers list only List and Set. Queue (and Deque) is the third branch, with
LinkedListandPriorityQueueas implementations. - Confusing Collection with Collections.
Collection(singular) is the interface;Collections(plural) is a utility class of static helpers likesortandunmodifiableList. - Putting Iterable in java.util.
Iterableactually lives injava.lang; everything below it lives injava.util.
Check your understanding
Answer these without looking back at the article.
- Why does Map not extend Collection?
- What is the difference between Collection and Collections?
- Which collection allows duplicates and which doesn't?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.