Class PatternMatchingSwitchDemo

java.lang.Object
modernfeatures.java17.PatternMatchingSwitchDemo

public class PatternMatchingSwitchDemo extends Object
This demo shows pattern matching for switch in Java 17+ using sealed interfaces and records. It illustrates how switch expressions can be used with pattern matching to handle different implementations of a sealed interface.
  • Constructor Details

    • PatternMatchingSwitchDemo

      public PatternMatchingSwitchDemo()
  • Method Details

    • main

      public static void main(String[] args)
      Iterates over different shapes and uses a switch expression with pattern matching to produce a description of each shape.