java.util.Set adds duplicate entries
<p>The below is my code,</p>

<pre><code>public class Myclass{
     some code is here.
   }

   public static void main(String args[]){
     Set&lt;Myclass&gt; set = new HashSet&lt;Myclass&gt;();
     Myclass mc = new Myclass();
     for(int i=0;i&lt;2;i++){
       set.add(mc);
     }
     System.out.println("size of set : "+set.size());
   }
</code></pre>

<p>The above code is print the output 2 but it will be 1. Is there any wrong with my code, if so then please suggest me how to avoid adding duplicate entries in set. I have override the equals() in my Myclass class.</p>

<p>Please reply me as soon as possible.</p>

<p>Thank you.</p>
