Java21 Pattern Matching For Switch
Java21 Pattern Matching For Switch
• Changes include:
• case labels can include patterns and null
• case labels can include optional when clauses (“guards”)
• selector expression types broadened
• from:
• integral primitive types (excluding long), their corresponding wrapper
types, String and enums.
• to:
• integral primitive types (excluding long) and any reference type.
• enum constant case labels improved
• qualified enum constants now allowed
3