Get the latest tech news
JEP-455: Primitive types in patterns, instanceof and switch
Types in Patterns, instanceof, and switch (Preview) Summary Enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types. This is a preview language feature.
Primitive type patterns in instanceof would subsume the lossy conversions built into the Java language and avoid the painstaking range checks that developers have been coding by hand for almost three decades. Instead of throwing an exception, it can silently lose information such as magnitude, sign, or precision, allowing the improperly cast value to flow into the rest of the program. Now that primitive type patterns can be used widely, matching is generalized to mean that a value can be cast exactly to T, which covers throwing a ClassCastException as well as potential loss of information.
Or read this on Hacker News