beginnerFree
Java Collections: The Family
Know the landscape before picking a collection

Java collections organize into interfaces - List, Set, Queue, and Map.
Watch
The narrated version of this skribble — tap play for the full-size video.
0:00 / 1:19
Deep dive
The Big Picture
The Collections Framework organizes Java's data structures.
- Under
Collection:List,Set,Queue/Deque Mapis a related interface, not aCollection- Common interface lets you swap implementations easily
- Part of
java.utilsince Java 1.2
Every Java program beyond basics uses collections.
How It Works
Collection types are Iterable (for-each); Map is not - iterate its keySet/values/entrySet views.
List: ordered, allows duplicates, index accessSet: unique elements, no guaranteed orderMap: key-value pairs, unique keysQueue/Deque: order depends on impl - FIFO queues, deque both ends, PriorityQueue by priority- Backed by arrays, linked lists, hash tables, or trees
In the Java Landscape
Java 9+ factory methods: List.of(), Set.of(), Map.of()
- These create unmodifiable collections
- Streams (Java 8+) transform collections functionally
Collectionsutility class: sort, shuffle, sync wrappers- Guava and Apache Commons extend the framework
- Concurrent collections in
java.util.concurrent
Pitfalls and Best Practices
- Program to interface:
List<T>notArrayList<T> - Choose implementation by access pattern and data needs
- Prefer
List.of()for small immutable collections - Don't mix mutable and unmodifiable references
- Size collections when capacity is known



