Incorrect overriding of "equals"? : <p>got stuck on the test tusk:</p>

<pre><code> class MyKeys {
 Integer key;
 MyKeys(Integer k) {
 key = k;
 }
 public boolean equals(Object o) {
 return ((MyKeys) o).key == this.key;
 }
}
</code></pre>

<p>And this code snippet:</p>

<pre><code>Map m = new HashMap();
MyKeys m1 = new MyKeys(1);
MyKeys m2 = new MyKeys(2);
MyKeys m3 = new MyKeys(1);
MyKeys m4 = new MyKeys(new Integer(2));
m.put(m1, "car");
m.put(m2, "boat");
m.put(m3, "plane");
m.put(m4, "bus");
System.out.print(m.size()); 
</code></pre>

<p>So, my expected output would be "2", while it's actually 4. I guess there is some problem with correctness of overriding equals method. Any help is useful. </p>
