Skip to content
JavaAgentic

Type at least two characters. Try “RAG”, “pgvector” or “tool calling”.

Interview Prep · Phase 3

Collections & Data Structure Internals

What is actually inside the collection you picked: array growth and copying, hash buckets and treeification, red-black trees, the difference between a fail-fast and a fail-safe iterator, and the memory each structure really costs per element.

Beginner6 min read

The Collections Framework Map

The interface hierarchy and what each contract promises, why some methods throw UnsupportedOperationException by design, and the differences between Arrays.asList, List.of and List.copyOf.

Read tutorial
Beginner6 min read

ArrayList vs LinkedList: Internals and Growth

What each one stores in memory, the 1.5x growth and array copy, why LinkedList loses even at insertion in the middle, and the per-element overhead that makes cache locality decide the winner.

Read tutorial
Intermediate7 min read

HashMap Internals: Buckets, Resize and Treeification

How HashMap stores entries, why the hash is XORed with its own high bits, what happens during a resize, when a bucket becomes a red-black tree, and the Java 7 race that caused infinite loops.

Read tutorial
Advanced7 min read

ConcurrentHashMap vs Hashtable vs synchronizedMap

How ConcurrentHashMap achieves concurrency without a global lock, why segments disappeared in Java 8, the computeIfAbsent deadlock, and why size() is only an estimate.

Read tutorial
Intermediate6 min read

TreeMap, LinkedHashMap and Building an LRU Cache

How TreeMap uses a red-black tree for sorted keys and range queries, how LinkedHashMap adds a doubly-linked list for ordering, and building an LRU cache in ten lines with removeEldestEntry.

Read tutorial
Beginner6 min read

HashSet, LinkedHashSet and TreeSet

Why every Set is a Map underneath, how iteration order differs, the TreeSet comparator-equality trap, EnumSet as a bit vector, and choosing a Set for concurrent access.

Read tutorial
Intermediate6 min read

Queues, Deques and BlockingQueues

The three method families and why Queue has three ways to insert, choosing between ArrayBlockingQueue and LinkedBlockingQueue, PriorityQueue as a binary heap, and the SynchronousQueue handoff.

Read tutorial
Intermediate6 min read

Fail-Fast vs Fail-Safe Iterators

How modCount makes an iterator fail fast, why removing inside a for-each throws, the four correct ways to remove while iterating, and what weakly consistent iteration actually promises.

Read tutorial
Intermediate7 min read

Choosing a Collection: Complexity and Memory Footprint

A complete Big-O table for every common collection, what each one actually costs per element in bytes, why boxing dominates numeric collections, and a decision procedure that fits on one page.

Read tutorial