title: LinkedHashSet: hashCode() and equals() match, but contains() doesn't
body: <p>How is the following possible:</p>
  
  <pre><code>void contains(LinkedHashSet data, Object arg) {
      System.out.println(data.getClass()); // java.util.LinkedHashSet
      System.out.println(arg.hashCode() == data.iterator().next().hashCode()); // true
      System.out.println(arg.equals(data.iterator().next())); // true
      System.out.println(new ArrayList(data).contains(arg)); // true
      System.out.println(new HashSet(data).contains(arg)); // true
      System.out.println(new LinkedHashSet(data).contains(arg)); // true (!)
      System.out.println(data.contains(arg)); // false
  }
  </code></pre>
  
  <p>Am I doing something wrong?</p>
  
  <p>Obviously, it doesn't always happen (if you create a trivial set of Objects, you won't reproduce it). But it does always happen in my case with more complicated class of arg.</p>
  
  <p><strong>EDIT</strong>: The main reason why I don't define <code>arg</code> here is that's it's fairly big class, with Eclipse-generated <code>hashCode</code> that spans 20 lines and <code>equals</code> twice as long. And I don't think it's relevant - as long as they're equal for the two objects.</p>