Java 26 — JEP 530: Primitive patterns and switch (Preview) int i = 1000; if ( i instanceof byte b ) { System.out.println( "fits in byte: " + b ); } boolean v = true; switch ( v ) { case true -> System.out.println( "YES" ); case false -> System.out.println( "NO" ); } • Pattern matching now works with primitive types, not only reference types. • The instanceof test can check whether a conversion is exact before binding a variable. • switch also extends to primitive selectors such as boolean, long, float, and double. #java #jdk26 #java26 #jep #jep530 #pathtojava27 #primitive #switch Go further with Java certification: Java👇 https://bit.ly/javaOCP Spring👇 https://bit.ly/2v7222 SpringBook👇 https://bit.ly/springtify JavaBook👇 https://bit.ly/jroadmap

To view or add a comment, sign in

Explore content categories