Originally posted by David O'Meara:
What you quoted was a statement of intent, not a statement of fact. Or to paraphrase myself, they are hinting that you should always override hashCode when you override equals. Otherwise you could define an equals contract that returns different hashCode values and things would just start breaking and you may never know why...
In particular, many classes from the Collections framework will break. This is the main intent of this particular contract, from what I understand. In particular, HashMap() and HashSet() use the hashCode() method, so if you don't conform to the contract between hashCode() and equals(), these two collections may have odd behaviors.
In general, the equals() method does NOT call the hashcode() method. Although, you COULD write it this way if you want. However, notice that it isn't necessary to fulfill the contract. In fact, it might not be a good idea since the contract only specifies one direction: if a.equals(b) returns true, then a.hashcode() should equal b.hashcode(). It is quite possible to write a hashcode() method that returns equal values for two objects such that the equals() method still returns false. This doesn't break the contract.
Layne