title: Why is the implementation of Object.equals() not using hashCode()?
body: <p>or <em>"Why do the Sun/Oracle guys force us to override both equals() and hashCode() everytime?"</em></p>
  
  <p><a href="https://stackoverflow.com/questions/27581/overriding-equals-and-hashcode-in-java">Everyone knows</a> that, if you override equals() or hashCode() of an object, you have to override the other one, too, because there is a contract between those two:</p>
  
  <blockquote>
    <p>Note that it is generally necessary to override the hashCode method whenever this method [i.e. equals()] is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
    -- <em><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals%28java.lang.Object%29" rel="nofollow noreferrer">API doc of Object.equals()</a></em></p>
  </blockquote>
  
  <p>Why isn't it implemented that way in the Object class:</p>
  
  <pre><code>public boolean equals(Object obj) {
      return this.hashCode() == obj.hashCode()
  }
  </code></pre>
  
  <p>If they did this, it would have saved the rest of the world from having to implement both methods. It would be enough to override only hashCode().</p>
  
  <p>I guess the guys had some good reason not to do this. I just cannot see it - please clear this up for me.</p>