ProLesson 13.4Intermediate2 min readUpdated 30 October 2026
Java 12 to 17: records, sealed classes and pattern matching
Switch expressions, text blocks, records, pattern matching for instanceof, sealed classes and helpful NullPointerExceptions, all final by Java 17 LTS.
Between Java 12 and 17, Java gained features that make everyday code shorter and safer. By Java 17 (LTS, 2021) all of these are final, and Java 17 is still one of the most common versions in production.
01The features and when they became final
| Feature | Final in | Lesson |
|---|---|---|
Switch expressions (->, yield) | Java 14 | 2.4 |
| Helpful NullPointerException messages | Java 14 (on by default in 15) | 5.5 |
Text blocks (""") | Java 15 | 3.5 |
| Records | Java 16 | 4.9 |
Pattern matching for instanceof | Java 16 | 4.6 |
Stream.toList() | Java 16 | 8.5 |
| Sealed classes | Java 17 | 4.9 |
Loading the rest of the lesson…