Εγγραφές

Παράδειγμα


public class RecordDemo {
    record Point(int x, int y) {}

    public static void main(String[] args) {
        var a = new Point(5, 12); // Pythagorean triple
        System.out.println("Point " + a + " has magnitude "
                + Math.sqrt(a.x() * a.x() + a.y() * a.y()));
    }
}