title: Why does a HashTable store the hash value of the key in the table in java
body: <p>I was going through Java's implementation of the put method for a hashtable and came across this : </p>
  
  <pre><code>// Makes sure the key is not already in the hashtable.
      Entry tab[] = table;
      int hash = key.hashCode();
      int index = (hash &amp; 0x7FFFFFFF) % tab.length;
      for (Entry&lt;K,V&gt; e = tab[index] ; e != null ; e = e.next) {
          if ((e.hash == hash) &amp;&amp; e.key.equals(key)) {
              V old = e.value;
              e.value = value;
              return old;
          }
      }
  </code></pre>
  
  <p>While I understand that a key is required to check for collisions, why is Java storing the hash value of the key and also checking it ? </p>