Zest.

Java: Record

A short, tested Java example for record. Copy it and adjust the names and paths for your project.

Java
public record Point(int x, int y) {
    public double distance() { return Math.sqrt(x * x + y * y); }
}

var p = new Point(3, 4);
System.out.println(p.x() + " " + p.distance());

Find it in Zest

Search for “java record” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Java examples

All Java examples