Records and Pattern Matching
- Records. A record declares immutable data in one line: constructor, accessors, equals and hashCode generated honestly.
- Pattern matching. Pattern matching deconstructs: if (shape instanceof Circle c) binds c, typed, in the condition itself.
- Switch patterns. Switch now matches types and record shapes: with sealed hierarchies, the compiler checks exhaustiveness.
Modern Language Features
- var. var infers a local variable’s type from the initialiser: less ceremony, same static safety.
- Text blocks. A text block spans lines between triple quotes: SQL and JSON embedded without escape soup.
- Sealed plus records. Sealed interfaces over records model algebraic data: every case named, every switch checked.
Writing Idiomatic Current Java
- Immutability by default. Modern Java defaults to immutable: records, List.of, final fields: mutation as the exception.
- Smaller ceremonies. Idiomatic code drops legacy ceremony: no getters on records, no boilerplate the language now writes.
- Reading era by style. Codebases carry their era: recognising 2005-style Java tells you which refactors pay first.
Before and after this level
- Before: Level 12: Testing: Unit and Integration Tests, Mocking and Test Design, Maintainable Java Test Suites.
- Next: Level 14: Performance: Profiling, Memory and Concurrency Performance, JVM Tuning Fundamentals.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Java Level 13: Modern Java cover?
Records and Pattern Matching, Modern Language Features, Writing Idiomatic Current Java: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 12: Testing, which covers Unit and Integration Tests, Mocking and Test Design, Maintainable Java Test Suites.