Learn Java
import com.learnjava.packagesstandardlibrary.CollectionsFrameworkOverview;

The Collections Framework Overview in Java

@Concept

The Java Collections Framework is the unified set of interfaces and classes for working with groups of objects, and nearly everything in it traces back to a small number of core interfaces: Collection is the root, with List (ordered, allows duplicates, like ArrayList), Set (no duplicates, like HashSet), and Queue (typically processed in a specific order, like LinkedList used as a queue) each extending it in their own direction. Map sits slightly apart, storing key-value pairs rather than standalone elements, and doesn't actually extend Collection at all.

This shared interface structure is exactly why code can often be written against List or Set generically, without caring which specific implementation, ArrayList versus LinkedList, HashSet versus TreeSet, is actually behind it. Swapping one implementation for another later, when performance characteristics genuinely call for a change, doesn't require touching the code that merely uses the interface type.

@HowItWorks
1

Collection

The root interface most of the framework builds on, representing a general group of elements.

2

List

Ordered, allows duplicate elements, accessed by index; ArrayList and LinkedList are its two most common implementations.

3

Set

No duplicate elements allowed at all; HashSet and TreeSet are its two most common implementations.

4

Queue

Elements typically processed in a specific order, like first-in-first-out; LinkedList can serve as one.

5

Map

Stores key-value pairs, sitting apart from Collection entirely rather than extending it; HashMap and TreeMap are its most common implementations.

@Example
import java.util.List;
import java.util.ArrayList;
 
public class FrameworkDemo {
static void printSize(List<String> list) {
System.out.println("Size: " + list.size());
}
 
public static void main(String[] args) {
List<String> names = new ArrayList<>();
names.add("Ana");
names.add("Bo");
printSize(names);
}
}
Output
Size: 2
1printSize accepts a List, the interface, rather than an ArrayList specifically, the concrete implementation.
2names is created as an ArrayList, one particular implementation of the List interface.
3printSize(names) works correctly, since an ArrayList genuinely is a List through that shared interface relationship.
4The single println call inside printSize shows the correct size, having never needed to know which specific List implementation it actually received.
@UseCases
Writing a method that accepts List, Set, or Map generically instead of one specific implementation
Swapping ArrayList for LinkedList, or HashSet for TreeSet, later without changing code that only depends on the shared interface
Understanding why Map doesn't extend Collection the way List, Set, and Queue all do
Choosing the right core interface, List, Set, Queue, or Map, based on what a problem actually needs: order, uniqueness, or key-based lookup

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in Java yourself — building beats watching.