Collections Framework
The Java Collections Framework defines the standard data-structure interfaces and implementations every Java program depends on. Choosing the right collection —
ArrayListvs.LinkedList,HashMapvs.TreeMap— and understanding the contracts ofequals,hashCode, and ordering is essential for writing correct, performant code.
What You'll Find Here
Notes are being added. Planned topics:
| Topic | Description |
|---|---|
| Collections Hierarchy | Iterable → Collection → List/Set/Queue; why Map is separate. |
| List | ArrayList (O(1) get) vs. LinkedList (O(1) add/remove at ends). |
| Set | HashSet, LinkedHashSet, TreeSet — duplicates, ordering, performance. |
| Map | HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap — choosing the right map. |
| Queue & Deque | ArrayDeque, PriorityQueue, BlockingQueue for task patterns. |
| Iterators & for-each | Iterator protocol, ConcurrentModificationException, enhanced-for loop. |
| Sorting & Ordering | Comparable (natural order on the class) vs. Comparator (external order). |
| Immutable Collections | List.of, Set.of, Map.of (Java 9+); Collections.unmodifiableList. |
Learning Path
- Collections Hierarchy — understand the interface tree before picking an implementation.
- List —
ArrayListis the default; understand O-complexity trade-offs vs.LinkedList. - Map —
HashMapinternals (buckets, load factor, Java 8 tree bins) are a classic interview deep-dive. - Set — relies on correct
equals/hashCode; review Core APIs first. - Sorting & Ordering —
Comparablevs.Comparatorappears in almost every Java interview. - Immutable Collections — factory methods from Java 9+ are the modern best practice.
Related Domains
- Core APIs —
Object.equals/hashCodegovernsHashMapandHashSet. - Java Type System — generics define
List<T>,Map<K,V>, and wildcards. - Multithreading & Concurrency —
ConcurrentHashMap,BlockingQueue, and thread-safe wrappers.