title: contains function not calling the equals method to compare objects
body: <p>I am using SQL query to get the Person object. This Person object has a set of interests which also I am getting from SQL query. </p>
  
  <p>Now when I try to check if a interest object is contained in this Person Object, then it is not calling the equals method to check it.</p>
  
  <p>Following is my code</p>
  
  <pre><code>class Interest {
  
  
  private Person person ;
  
  private Admin admin ;
  
  //getter setters for Person and admin 
  public boolean equals(Object arg0) {
          // TODO Auto-generated method stub
  
  
          if (!(arg0 instanceof Interest)) {
              return false;
          }
  
          if (this==arg0){
              return true;
          }
  
          if(this.person.equals(((Interest)arg0).getPerson()) &amp;&amp; this.admin.equals(((Interest)arg0).getAdmin()))
          {
              return true;
          }
  
          return false;
      }
  
      /* (non-Javadoc)
       * @see java.lang.Object#hashCode()
       */
      @Override
      public int hashCode() {
          // TODO Auto-generated method stub
          int hc=0;
  
          if(this.person !=null)
              hc= hc + 19 * this.person.getName().length();
  
          if(this.admin !=null)
              hc= hc + 19 * this.admin.getName().length();
  
          return hc;
      }
  
      public int compareTo(Object arg0) {
      // TODO Auto-generated method stub
      String objStr = ((Interest)arg0).person.getName().toUpperCase();
      int value =  this.person.getName().toUpperCase().compareTo(objStr);
  
      return value;
  }
  
  }
  </code></pre>
  
  <p>Now in the person class I am having code as follows :</p>
  
  <pre><code>class Person {
  
  private Set interest ;
  
  
  //other fields 
  
  //getter and setters 
  
  public boolean isInterestExists(Interest interest){
  
  return this.interest.contains(interest);
  }
  
  }
  </code></pre>
  
  <p>Now I am executing this from </p>
  
  <pre><code>person.isInterestExists(interest);
  </code></pre>
  
  <p>It is not calling the equals method of Interest class. Where did I go wrong?</p>