title: What is the time complexity performance of HashSet.contains() in Java?
body: <p>I'm tempted to think that the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/HashSet.html#contains(java.lang.Object)" rel="noreferrer">HashSet.contains(Object)</a> method performs in constant time. It simply gets the hash code of an object and then looks it up in a hash table.</p>
  
  <p>First, could someone please confirm whether this is true? </p>
  
  <p>Second, if it is true, is there any risk of collisions, where two objects might have the same hash code and thus the HashSet thinks it has both when it only has one?</p>