title: HashMap having null as key
body: <p>How <code>HashMap</code> internally differentiate between <code>null</code> and <code>0</code> as key. </p>
  
  <p>As per this <a href="https://stackoverflow.com/questions/17268212/hashcode-for-null-key-in-hashmap">post</a> the hash code for <code>null</code> key is <code>0</code>, Is it correct?
  If yes then both should go in same bucket at index <code>0</code> and there should be one value in the <code>HashMap</code> but this is not how <code>HashMap</code> works. </p>
  
  <p>Can somebody explain me? what is the hash code for <code>null</code> key in <code>HashMap</code>?</p>
  
  <p>Sample code:</p>
  
  <pre><code>HashMap&lt;Integer,String&gt; map=new HashMap&lt;Integer,String&gt;();
  map.put(null, "abc");
  map.put(0, "xyz"); // will it override the value for null as key?
  
  System.out.println(map.get(null));  // abc
  System.out.println(map.get(0));     // xyz
  </code></pre>