title: implement 2 flavors of Equals method for a class in Java
body: <pre><code>public class Foo{
      private final int A;
      private final int B;
      public boolean equals(Object o){
          //type check omitted
          return A==o.A &amp;&amp; B==o.B;
      }
  
  }
  </code></pre>
  
  <p>I want to have another <code>.equals()</code> method like this</p>
  
  <pre><code>public boolean equals(Object o){
      return A==o.A;
  }
  </code></pre>
  
  <p>The Foo object is first created with A,B field, then I want to send them off to a <code>Set&lt;E&gt;</code> that used the 2nd equals() method to <strong>only compares field A</strong>.</p>
  
  <p>I know I can create new objects that only have A field, but overhead would be big. Any advice?</p>