Class RecordPatternsExamples

java.lang.Object
net.jrodolfo.java_evolution.java21.RecordPatternsExamples

public class RecordPatternsExamples extends Object
Demonstrates record patterns, finalized in Java 21.

Records make transparent data carriers concise, but code often needs to read the components back out. Record patterns let code test the type and bind record components in one expression, which is especially useful for nested records.

  • Constructor Details

    • RecordPatternsExamples

      public RecordPatternsExamples()
  • Method Details

    • describe

      public String describe(Object shape)
      Deconstructs nested records.
      Parameters:
      shape - the shape to describe
      Returns:
      a text description