Top
image credit: Unsplash

Java Enhances Pattern Matching with Primitive Type Support in JEP 455

February 2, 2024

Via: InfoQ

JEP 455, Primitive Types in Patterns, instanceof, and switch (Preview), has been promoted from Proposed to Target to Targeted for JDK 23. This JEP, under the auspices of Project Amber, proposes to enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types. Aggelos Biboudis, principal member of technical staff at Oracle, has recently published an updated draft specification for this feature.

This proposal allows developers to directly test and convert between different primitive types, such as int, byte, and float, without the verbose syntax traditionally required for such operations.

Read More on InfoQ