import java.util.Objects; // "Convert record to class" "true-preview" final class Point { private final double x; private final double y; Point(double x, double y) { this.x = x; this.y = y; } void foo() { } public double x() { return x; } public double y() { return y; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; Point that = (Point) obj; return Double.doubleToLongBits(this.x) == Double.doubleToLongBits(that.x) && Double.doubleToLongBits(this.y) == Double.doubleToLongBits(that.y); } @Override public int hashCode() { return Objects.hash(x, y); } @Override public String toString() { return "Point[" + "x=" + x + ", " + "y=" + y + ']'; } }