title: Does IdentityHashMap entertain collisions?
body: <p>As per the <a href="http://docs.oracle.com/javase/7/docs/api/" rel="nofollow">Javadocs</a> of <code>IdentityHashMap</code>, it says</p>
  
  <blockquote>
    <p>This class implements the <code>Map</code> interface with a hash table, using
    reference-equality in place of object-equality when comparing keys
    (and values). In other words, in an <code>IdentityHashMap</code>, two keys k1 and
    k2 are considered equal if and only if <code>(k1==k2)</code>. (In normal <code>Map</code>
    implementations (like <code>HashMap</code>) two keys k1 and k2 are considered equal
    if and only if <code>(k1==null ? k2==null : k1.equals(k2))</code>.)</p>
  </blockquote>
  
  <p>As I understand, two different objects pointing to different memory locations can still have same hashcode hence <code>object1.equals(object2)</code> can return <code>true</code>.
  But two different objects pointing to different memory locations can never return <code>true</code> for <code>object1 == object2</code>.</p>
  
  <p><strong>Question 1</strong> - when <code>IdentityHashMap</code> relies strictly on reference equality, does that mean collisions will never occur?</p>
  
  <p><strong>Question 2</strong> - debugging the following code shows me 6 buckets in all with key and value both stored in separate buckets. But this is not the case with <code>HashMap</code>, where the key and value are stored in the same bucket. </p>
  
  <p>As it's name has a 'hash' word in it, so it must be hashing the keys, then why does it store the keys and values separately and how does it retrieve the value of a given key?</p>
  
  <pre><code>String A = "abc";
  String B = "def";
  String C = new String("abc");
  Map&lt;String, String&gt; map1 = new IdentityHashMap&lt;String, String&gt;();
  map1.put(A, "123");
  map1.put(B, "345");
  map1.put(C, "567");
  </code></pre>