The Collections Framework Overview in Java
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.
Collection
The root interface most of the framework builds on, representing a general group of elements.
List
Ordered, allows duplicate elements, accessed by index; ArrayList and LinkedList are its two most common implementations.
Set
No duplicate elements allowed at all; HashSet and TreeSet are its two most common implementations.
Queue
Elements typically processed in a specific order, like first-in-first-out; LinkedList can serve as one.
Map
Stores key-value pairs, sitting apart from Collection entirely rather than extending it; HashMap and TreeMap are its most common implementations.
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); }}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Java yourself — building beats watching.