???????????????????p????????????????????????????????p????????????????????????

Iterator<Point> it = coll.iterator();
boolean containedP = false;
while (it.hasNext()) {
    Point nextP = it.next();
    if (nextP.equals(p)) {
        containedP = true;
        break;
    }
}

System.out.println(containedP); // ??? true

???????????????в?????p??????p??????????У??????????????????????е?????ж?????x??????????????p????hashCode???????coll?????????С??????????????????????????????????仰???p????????coll?????????Χ???????????????coll??????

???????????????????????????equals??hashCode???????仯?????????????????????????????????????????????У????????С???????????Щ??Щ???????????????????????С???塣???????????????????????б??????????ò?????????equals?????????????????????????equals???????????Point???????壬?????????hashCode?????????????????????????equalsContents?????????????equals??????????Point?????????????equals??hashCode???????????????????x???p??????????????????????????λ?á?

????????4??????????????equals??????

????Object?е?equals??淶??????equals??????????????null?????????????

?????? ???????????κη?null?X??????x.equals(x)?????true??

?????? ???????????κη???x??y????????????y.equals(x)?????????x.equals(y)?????檔

?????? ????????????κη???x??y????z?????x.equals(y)?????棬??y.equals(z)??????棬???x.equals(z)???÷????檔

?????? ????????????x??y????ε???x.equals(y)?????μ?????????????equals??????????????????e?????????????

?????? ?????κη???x??x.equals(null)????????false.

????Point???equals???????????????????????equals?淶????塣??????????????е???????????÷??????????????????????Point??????ColoredPoint??????Point?????????????????Color??color??????Color??????????????????

public enum Color {
    RED?? ORANGE?? YELLOW?? GREEN?? BLUE?? INDIGO?? VIOLET;
}

????ColoredPoint??????equals??????????????????color?????????£?

public class ColoredPoint extends Point { // Problem: equals not symmetric

    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 = (this.color.equals(that.color) && super.equals(that));
        }
        return result;
    }
}