Looking at Java 21: Record Patterns

Pattern matching is a declarative and composable approach that creates more powerful and expressive code for data structure navigation and processing. Java 16 added pattern matching for the instanceof operator (JEP 394), and we looked at pattern matching for switch in this series before (Switch Pattern Matching. Today, it’s time to take a quick look at another kind of pattern matching: Record Patterns (JEP 440).

Looking at Java 21: Feature Deprecations

Even though Java is one of the most backward-compatible languages and environments I’ve ever worked with, there’s always the possibility of feature deprecations and even removals. Java 21 will deprecate two features, so that’s what we’re looking at today.

Looking at Java 21: Switch Pattern Matching

The switch control structure has quite an evolution lately since its inception. First, there were switch expressions (JEP 325, 354, 361). And now, we get pattern matching for switch statements and expressions!

Looking at Java 21: Scoped Values

Today we look at Scoped Values, another interesting preview feature that’s incubating since Java 20 (JEP 429). It’s a new way to store and share immutable data with a bounded lifetime within a thread and its child threads.

Looking at Java 21: Sequenced Collections

Dealing with Collections is improving with Java 21, as three new interfaces get retro-fitted right into the existing type hierarchies. These Sequenced Collections give us a uniform API to access the first and last elements, and process Collections in reverse.