Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: DSA in Java
Stage 5: Specialization

Part 14 / Topic 6 of 7

What's new, Java 17 → 21

This course pins Java 21 (LTS). Everything used in this part shipped as a preview feature at some point along the way and was finalized by 21 — worth knowing which release actually locked each one in, since code written against an earlier preview can look almost, but not quite, the same.

Feature Finalized in Notes
Pattern matching for instanceof (JEP 394) 16 Section 2
Sealed classes and interfaces (JEP 409) 17 (LTS) Section 1; permits, final/sealed/non-sealed
Pattern matching for switch (JEP 441) 21 (LTS) Section 3; went through several preview rounds across 17–20 first
Record patterns (JEP 440) 21 (LTS) Section 4; previewed in 19 and 20 before finalizing
Virtual threads (JEP 444) 21 (LTS) Covered in Part 12; one JVM thread no longer means one OS thread
Sequenced collections (JEP 431) 21 (LTS) List/Set/Map gain getFirst()/getLast()/reversed() — met in Part 8
ScopedValue preview in 21, finalized in 25 Part 12's ThreadLocal successor; still a preview on this course's pinned JDK

Both of this course's LTS releases sit at the ends of that table: 17 closed the hierarchy story (sealed) and 21 closed the pattern-matching story (switch patterns, record patterns) that sealed was building toward the whole time. If you only remember one thing from this section: a sealed interface of records (sections 1 and 5) is what an exhaustive, deconstructing switch (sections 3 and 4) is designed to consume — the four features in this part are one idea, shipped across five releases.

Done here? The practice set for Part 14 — including the solutions — is on the part page.

Search the guide