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. Before record patterns, code first checked the type, then called accessors such as rectangle.topLeft().x() to reach nested values. 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