Java – Pattern Matching (Java 16+)
Java introduced Pattern Matching for type checks with instanceof in Java 16.
Example:
Object obj = "Hello";
if (obj instanceof String s) {
System.out.println(s.toUpperCase());
}
No images available.
Java introduced Pattern Matching for type checks with instanceof in Java 16.
Example:
Object obj = "Hello";
if (obj instanceof String s) {
System.out.println(s.toUpperCase());
}
No images available.