Java: Use hashCode() inside of equals() for convenience?

In general, it’s not at all safe to compare the hashCode instead of using equals. When equals returns false, hashCode may return the same value, per the contract of hashCode.

Leave a Comment