title: How does a Java HashMap handle different objects with the same hash code?
body: <p>As per my understanding I think:</p>
  
  <ol>
  <li>It is perfectly legal for two objects to have the same hashcode.</li>
  <li>If two objects are equal (using the equals() method) then they have the same hashcode.</li>
  <li>If two objects are not equal then they cannot have the same hashcode</li>
  </ol>
  
  <p>Am I correct?</p>
  
  <p>Now if am correct, I have the following question:
  The <code>HashMap</code> internally uses the hashcode of the object. So if two objects can have the same hashcode, then how can the <code>HashMap</code> track which key it uses?</p>
  
  <p>Can someone explain how the <code>HashMap</code> internally uses the hashcode of the object?</p>