import java.util.*;
// *** before: ***
class PointOld {
private final int x;
private final int y;
PointOld(int x, int y) { this.x = x; this.y = y; }
public int x() { return x; }
public int y() { return y; }
public boolean equals(Object o) {
if (!(o instanceof PointOld)) return false;
PointOld p = (PointOld) o;
return x == p.x && y == p.y;
}
public int hashCode() { return Objects.hash(x, y); }
public String toString() { return "PointOld[x=" + x + ", y=" + y + "]"; }
}
// *** in version 16: ***
record Point(int x, int y) { } // all of the above, and that is the class
var p1 = new Point(3, 4);
var p2 = new Point(3, 4);
System.out.println(p1); // Point[x=3, y=4]
System.out.println(p1.x() + p1.y()); // 7
System.out.println(p1.equals(p2)); // true
System.out.println(p1.hashCode() == p2.hashCode());
// a record is final, its fields are final and there are no setters