title: how to know if the map contains that object based on the object properties
body: <p>I am using a map and want to use a value object as a map key..and a list as value. The value object has 2 properties first name, second name..i want to return map.containsKey() as true if both properties matched by some key in the same map..</p>
  
  <p>I tried to use comparator as below</p>
  
  <pre><code>public class comaparatorEx  implements Comparator&lt;Test&gt;{
      public static void main(String args[]){
  
          Map m= new HashMap&lt;Test,List&lt;String&gt;&gt;();
          Test t = new Test();
          t.setFirstname("vamsi");
          t.setSecondname("priya");
  
          List descriptionList=new ArrayList();
          descriptionList.add("description1");
          m.put(t, descriptionList);
          Test t2 = new Test();
          t2.setFirstname("vamsi");
          t2.setSecondname("priya");
  
          if(m.containsKey(t2)){
              System.out.println("user found");
          }           
      }
  
      public int compare(Test o1, Test o2) {
      if((o1.firstname.equals(o2.firstname) )&amp;&amp; o1.secondname.equals(o2.secondname))
          return 0;
      else return 1;
      }
  }
  </code></pre>
  
  <p>this is the value object i am using</p>
  
  <pre><code>public class  Test  {
  
  String firstname;
  String secondname;
  
  public String getFirstname() {
      return firstname;
  }
  public void setFirstname(String firstname) {
      this.firstname = firstname;
  }
  public String getSecondname() {
      return secondname;
  }
  public void setSecondname(String secondname) {
      this.secondname = secondname;
  }
  
  }
  </code></pre>
  
  <p>But it returns false for me..please help me ..thanks in advance</p>