Learning goals
By the end of this chapter you should be able to:
- Name headline features of Java 8, 11, 17, 21, 25 LTS releases
- Explain why teams pick an LTS baseline and what “preview” features mean
- Tie version features to code you have written: streams, records, virtual threads
- Answer “what changed since Java 8?” in interview breadth
Versions are a capability timeline
You have used java.time, streams, records, and virtual threads in this course — each landed in a specific release. Knowing when a feature arrived helps you read legacy code, set sourceCompatibility, and argue for upgrades.
Release cadence: feature release every 6 months; LTS every 2 years (8 → 11 → 17 → 21 → 25 → 29).
Production services usually standardize on the newest LTS their org certifies — not every six-month build.
The notes below are your interview cheat sheet per LTS: what shipped, what to migrate away from, and one-liner answers recruiters expect.
A short, interview-focused cheat sheet of the headline features per major version. LTS = Long-Term Support release (the ones companies actually deploy).
Cadence: a new Java release every 6 months, an LTS every 2 years: 8 → 11 → 17 → 21 → 25 → 29.
Java 8 (2014, LTS) — the baseline
- Lambdas and functional interfaces (
Function,Predicate,Consumer, …). - Streams API —
list.stream().filter(...).map(...).collect(...). Optional<T>for null-safe returns.java.time— modern date/time (replacesDate/Calendar).- Default and static methods on interfaces.
CompletableFuturefor async pipelines.
Java 11 (2018, LTS) — first post-8 LTS
varfor local variable type inference (added in 10).- Collection factories:
List.of(...),Set.of(...),Map.of(...)(added in 9). - New
Stringmethods:isBlank(),strip(),lines(),repeat(n). - Standard
HttpClientinjava.net.http(replacesHttpURLConnection). Files.readString/writeString.- Removed: bundled Java EE modules (
javax.xml.bind, etc.) — pulljakarta.*separately.
Java 17 (2021, LTS) — most common production target today
- Records — concise immutable data carriers:
record Point(int x, int y) {}. - Sealed classes — restrict who can extend:
sealed interface Shape permits Circle, Square {}. - Pattern matching for
instanceof—if (o instanceof String s) { use(s); }. - Switch expressions with
->andyield(from 14). - Text blocks —
"""…"""multi-line strings (from 15). Stream.toList()—stream.toList()replaces.collect(Collectors.toList())(from 16). Returns an unmodifiable list; usecollect(Collectors.toList())if you need a mutableArrayList.- Helpful NullPointerExceptions — error names the null variable.
Java 21 (2023, LTS) — current hot topic
- Virtual threads (Project Loom) — millions of lightweight threads via
Thread.startVirtualThread(...)/Executors.newVirtualThreadPerTaskExecutor(). Game-changer for blocking-I/O servers. - Sequenced Collections —
getFirst(),getLast(),reversed(),pollFirstEntry(), … onList,Deque,LinkedHashSet,LinkedHashMap. - Pattern matching for
switch— full switch on type, withcase-level patterns. - Record patterns — destructure records:
if (o instanceof Point(int x, int y)) {...}. - Generational ZGC for very low pause times.
Java 25 (2025, LTS) — newest LTS
- Instance main methods & compact source files —
void main() { ... }runs withoutpublic static void main(String[])ceremony; great for scripts. - Module import declarations —
import module java.base;brings a whole module in one line. - Scoped values — safer, virtual-thread-friendly alternative to
ThreadLocal. - Generational ZGC is now the default ZGC mode.
- Various 22–24 preview features graduated (e.g. unnamed variables
_, stream gatherers).
Interview one-liners
| Question | Answer in one breath |
|---|---|
| “What’s new in 11 from 8?” | var, List.of/Set.of/Map.of, modern String helpers, standard HttpClient, EE modules removed. |
| “What’s new in 17 from 11?” | Records, sealed classes, pattern matching for instanceof, switch expressions, text blocks, Stream.toList(). |
| “What’s new in 21 from 17?” | Virtual threads, sequenced collections, pattern matching for switch, record patterns. |
| “What’s new in 25 from 21?” | Instance main / compact source files, module imports, scoped values, generational ZGC default. |
| “Which version do you target?” | “Java 21 LTS — we use virtual threads for I/O-heavy endpoints and sequenced collections for ordered caches.” |
Practice checkpoint
-
Which release introduced
varandList.of? Answer:varin 10; collection factories in 9 — commonly cited together with 11 LTS migration from 8. -
Records and sealed classes — which LTS? Answer: 17.
-
Virtual threads — which LTS? Answer: 21.
-
Why not jump to every 6-month release in prod? Answer: support/ vendor certification focuses on LTS; non-LTS get shorter support windows.
Interview angles
- 8 → 11: modules removed EE APIs,
HttpClient, string helpers — plan dependency upgrades. - 11 → 17: language modernization (records, sealed, pattern instanceof, text blocks).
- 17 → 21: virtual threads change concurrency design for blocking IO.
- Target version answer: “We ship on 21 LTS for virtual threads and long support” — tie to your stack.