If objectA.equals(objectB) returns true, objectA.hashCode() must equal objectB.hashCode(). Use equals() when you want to test equality because hashCode() is not gaurenteed to be unique for every value, because it's clearer, and because it will perform better. The hashCode() method exists to be used by data structures such as HashMap. A HashMap will allow very quick insertion and querying of entries, but it relies on the assumption that the values of hashCode() are reasonably varied. Look up hashtables for more information about the specifics.