Class PatternMatchingSwitchNestedDemo

java.lang.Object
modernfeatures.java21.PatternMatchingSwitchNestedDemo

public class PatternMatchingSwitchNestedDemo extends Object
Demonstrates Java 21+ pattern matching for switch with nested record patterns. This example showcases how to use pattern matching in switch expressions to handle various shapes, including nested groups of shapes.
  • Constructor Details

    • PatternMatchingSwitchNestedDemo

      public PatternMatchingSwitchNestedDemo()
  • Method Details

    • main

      public static void main(String[] args)
      Demonstrates pattern matching with nested groups and various shapes. Creates an array of shapes including simple shapes and nested groups, then uses a switch expression with nested patterns to describe each shape.