????canEqual ????

????????????????????????????譚???????????????????????????????????в???????????????????????淶????????????????????????????????????????????????equals??hashCode?????????????????????????·????????equals(??hashCode)???????????????????????????????????????????????????????????????????????????????????????????????equals???????????????canEqual????????????????????????

public boolean canEqual(Object other)

???????other ??????canEquals?????????????????????????????????÷????棬??????false???????????equals????????????????????????????????????????Point????μ???????????

public class Point {

    private final int x;
    private final int y;

    public Point(int x?? int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    @Override public boolean equals(Object other) {
        boolean result = false;
        if (other instanceof Point) {
            Point that = (Point) other;
            result =(that.canEqual(this) && this.getX() == that.getX() && this.getY() == that.getY());
        }
        return result;
    }

    @Override public int hashCode() {
        return (41 * (41 + getX()) + getY());
    }

    public boolean canEqual(Object other) {
        return (other instanceof Point);
    }

}

????????汾??Point???equals?????а????????????????????canEquals???????????????????????????????????????????Point?е?canEqual?????????е?Point??????????????

??????????ColoredPoint????????

public class ColoredPoint extends Point { // ????Υ???????

    private final Color color;

    public ColoredPoint(int x?? int y?? Color color) {
        super(x?? y);
        this.color = color;
    }

    @Override public boolean equals(Object other) {
        boolean result = false;
        if (other instanceof ColoredPoint) {
            ColoredPoint that = (ColoredPoint) other;
            result = (that.canEqual(this) && this.color.equals(that.color) && super.equals(that));
        }
        return result;
    }

    @Override public int hashCode() {
        return (41 * super.hashCode() + color.hashCode());
    }

    @Override public boolean canEqual(Object other) {
        return (other instanceof ColoredPoint);
    }
}