JAVA中类的种类的有关问题

img

public class Point {
private Double x;
private Double y;

public Point(Double x, Double y) {
    this.x = x;
    this.y = y;
}

@Override
public String toString() {
    return this.getClass().getSimpleName() + "{" +
            "x=" + x +
            ", y=" + y +
            '}';
}

@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof Point)) return false;
    Point point = (Point) o;
    return Objects.equals(getX(), point.getX()) && Objects.equals(getY(), point.getY());
}

@Override
public int hashCode() {
    return Objects.hash(getX(), getY());
}

public Double getX() {
    return x;
}

public void setX(Double x) {
    this.x = x;
}

public Double getY() {
    return y;
}

public void setY(Double y) {
    this.y = y;
}

public static void main(String[] args) {
    Point point1 = new Point(1.3,2.7);
    Point point2 = new Point(1.0,2.0);
    Point point3 = new Point(1.0,2.0);
    System.out.println(point1.toString());
    System.out.println(point2.equals(point3));
    System.out.println(point2.equals(point1));
}

}