Skip to main content

9 docs tagged with "collections"

View all tags

Collections Framework Interview Questions

Consolidated interview Q&A for the Java Collections Framework — hierarchy, List, Set, Map, Queue, iterators, sorting, and immutability — from beginner through advanced.

Collections Hierarchy

The complete interface tree of the Java Collections Framework — Iterable, Collection, List, Set, Queue, and why Map stands apart.

Immutable Collections

How to create truly immutable List, Set, and Map instances in Java using the Java 9+ factory methods and how they differ from the older Collections.unmodifiable wrappers.

Iterators and the for-each Loop

How the Iterator protocol works, what ConcurrentModificationException means and how to avoid it, and how the enhanced for-each loop is compiled.

List — ArrayList vs LinkedList

Understand Java's List interface, when to use ArrayList vs LinkedList, and how their internal structures drive performance trade-offs.

Sorting and Ordering — Comparable vs Comparator

Understand the difference between Comparable (natural ordering defined on the class) and Comparator (external ordering strategy), and how to use both with collections, streams, and sorted data structures.