// レコードクラスの定義 (これだけで全自動生成される!)
public record Point(int x, int y) {}
public class RecordExample {
public static void main(String[] args) {
Point p = new Point(10, 20); // 自動生成された正規コンストラクタ
// 自動生成されたアクセサメソッド (getX() ではなく component名と同名)
System.out.println(p.x()); // 10
System.out.println(p.y()); // 20
System.out.println(p); // 自動生成された toString -> Point[x=10, y=20]
}
}