title: Why index of hashcode is calculated in HashMap
body: <p>I was checking implementation of <code>HashMap</code> and in its <code>put</code> I see the after calculating the hash, index of the hash is calculated, like this <code>int i = indexFor(hash, table.length);</code>, and it is used as index of the underlying map.</p>
  
  <pre><code>/**
   * Returns index for hash code h.
   */
  static int indexFor(int h, int length) {
      return h &amp; (length-1);
  }
  </code></pre>
  
  <p>I searched didn't find any explanation to my question that why again index of the hash is calculated which is used as final index of the underlying data structure. What is the advantage of it over using the hash as index.</p>
  
  <p>I know it is nothing but bitwise AND but I want to know why it is done like this.</p>