HashSet contains method, strange behavior
<p>here is my code : </p>

<pre><code>public class testGui {



    public static void main(String[] arg){
        class TESTS{
            String t;

            public TESTS(String t){
                this.t = t;
            }

            @Override
            public boolean equals(Object x){
                System.out.println("My method is called...");
                if(x instanceof TESTS){
                    TESTS zzz = (TESTS) x;
                    return zzz.t.compareTo(t)==0;
                }
                else return false;
            }
        }
        HashSet&lt;TESTS&gt; allItems = new HashSet&lt;TESTS&gt;();
        allItems.add(new TESTS("a"));
        allItems.add(new TESTS("a"));
        System.out.println(allItems.contains(new TESTS("a")));
    }

}
</code></pre>

<p>I do not get why the hashset contains method is not calling my equals method as mentionned in their specifications :</p>

<blockquote>
  <p>More formally, adds the specified
  element, o, to this set if this set
  contains no element e such that
  (o==null ? e==null : o.equals(e))</p>
</blockquote>

<p>My code is returning false and not going into my equals method.</p>

<p>Thanks a lot for answering!</p>
