Class PatternMatchingSwitchPreviewExamples
java.lang.Object
net.jrodolfo.java_evolution.java17.PatternMatchingSwitchPreviewExamples
Demonstrates pattern matching for
switch as a Java 17 preview
feature.
Before pattern matching for switch, type-based branching often required a
chain of if, instanceof, and casts. That scattered the
dispatch logic across multiple statements.
Pattern matching for switch solves this by letting a switch branch on type patterns. It became final later, in Java 21. The executable method uses only type-pattern syntax that is faithful to both the Java 17 preview and the later feature; the README documents the historical guard syntax separately.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
PatternMatchingSwitchPreviewExamples
public PatternMatchingSwitchPreviewExamples()
-
-
Method Details
-
describe
-