Package modernfeatures.java21
Class PatternMatchingSwitchClassicDemo
java.lang.Object
modernfeatures.java21.PatternMatchingSwitchClassicDemo
Demonstrates both the classic instanceof/cast approach and the modern pattern matching for switch (Java 21+)
using a classic class hierarchy.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
PatternMatchingSwitchClassicDemo
public PatternMatchingSwitchClassicDemo()
-
-
Method Details
-
main
Demonstrates two approaches to type checking and handling: 1. Classic approach using instanceof and casting. 2. Modern approach using pattern matching for switch (Java 21+).
-