Collections for Javas
The Java Collections Framework is the standard set of interfaces and classes, such as List, Set, Map and Queue, for storing and managing groups of objects. Generics add compile-time type safety to them. This unit sits in the Core Libraries stage and covers the data structures most Java code relies on daily.
Stage: Core Libraries · Part of the Java roadmap · Last reviewed 19 November 2026
What to learn in Collections
- Pick between ArrayList, LinkedList, HashSet, TreeSet and HashMap for a given task
- Iterate a Map using entrySet and explain the cost of each lookup
- Write a generic method with a bounded type parameter
- Sort a list with Comparable and with a Comparator
- Explain why mutating a key inside a HashMap breaks lookups
Collections interview questions
How does a HashMap work internally in Java?
A HashMap computes the key's hashCode, maps it to a bucket index, and stores entries there. Collisions are chained in a linked list, which becomes a balanced tree when a bucket grows large. It resizes when the load factor is exceeded. Lookups are O(1) on average.
What is type erasure in Java generics?
The compiler checks generic types at compile time, then removes them and inserts casts, so List<String> and List<Integer> are the same class at runtime. This is why you cannot create a new T() or use instanceof with a parameterised type.
Where Collections fits in the Java roadmap
Collections belongs to the Core Libraries stage (intermediate level), which takes about 32 hours. Everyday APIs.