title: getting duplicate values in a Set of tuples
body: <p>I am trying to create a Set in java for a tuple of integers.</p>
  
  <p>For example:</p>
  
  <pre><code>class Tuple
  {
      int first;
      int second;
      public Tuple(int i, int j)
      {
          this.first=i;
          this.second=j;
      }
  }
  </code></pre>
  
  <p>And then trying to populate a set like this:</p>
  
  <pre><code>Set pairs = new HashSet&lt;Tuple&gt;();
  pairs.add(new Tuple(1,2));
  pairs.add(new Tuple(1,2));
  pairs.add(new Tuple(1,2));
  </code></pre>
  
  <p>For a number of tuple objects. But still I am getting duplicates by:</p>
  
  <pre><code>System.out.println("Size: " + pairs.size());
  for (Tuple t : (HashSet&lt;Tuple&gt;) pairs) {
      System.out.println(t.toString());
  }
  </code></pre>
  
  <p>Can anyone help to get rid of duplicates?</p>