title: A loop in HashMap.get
body: <p>This is a code to fetch a value from a key in HashMap. Why does it need to loop on line 317 to fetch the value ? Should this not be an O(1) operation ? </p>
  
  <pre><code>  public V get(Object key) {
    315           if (key == null)
    316               return getForNullKey();
    317           int hash = hash(key.hashCode());
    318           for (Entry&lt;K,V&gt; e = table[indexFor(hash, table.length)];
    319                e != null;
    320                e = e.next) {
    321               Object k;
    322               if (e.hash == hash &amp;&amp; ((k = e.key) == key || key.equals(k)))
    323                   return e.value;
    324           }
    325           return null;
    326       }
  </code></pre>