Nearby lessons
118 of 125Java 14 Features
- Switch expressions — now FINAL
- Records — the compact class (preview)
- Pattern matching for instanceof (preview)
- Helpful NullPointerException messages
- Text blocks second preview
Java 14 Features is a core concept of the Java language. This lesson explains Java 14 — Big Ideas Begin, Helpful NullPointerException Messages and Beyond Java 14 — What Comes Next (Your Roadmap) with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
Java 14 — Big Ideas Begin
Java 14 (March 2020) is the last version covered in the classic training material this book is based on. It finalized switch expressions and showed two preview features that will change how we write Java: Records and Pattern matching for instanceof. Both became final in Java 16.
Helpful NullPointerException Messages
Before Java 14, a NullPointerException was a mystery: just Exception in thread main java.lang.NullPointerException with no clue where.
The JVM now tells you exactly which method returned null and where the failure happened. Enable this by default since Java 15 (from Java 14, you could opt in with -XX:+ShowCodeDetailsInExceptionMessages).
Beyond Java 14 — What Comes Next (Your Roadmap)
This material's classic book ends at Java 14. As your 20+ years experienced trainer, here is the honest roadmap of what came after — so you are never outdated:
| Version | Headline features |
|---|---|
| Java 15 | Text blocks FINAL, ZGC final, sealed classes preview |
| Java 16 | Records FINAL, pattern matching for instanceof FINAL |
| Java 17 (LTS) | Sealed classes FINAL, strong encapsulation, long-term support |
| Java 18-20 | Small releases; simple web server, virtual threads preview |
| Java 21 (LTS) | Virtual threads, switch patterns, record patterns, String templates preview |
| Java 22-24 | String templates, structured concurrency previews, newer LTS cadence |
- Switch expressions became FINAL in Java 14.
- Records create data classes with automatic constructor, getters, toString, equals, hashCode.
- Pattern matching for instanceof combines check and cast into one step.
- Helpful NPE messages tell you exactly which value was null.
- Text blocks got a second preview before becoming final in Java 15.
- After Java 14: Java 15-24 added text blocks, records, sealed classes, virtual threads.