title: Work Flow of HashMap
body: <p>I have added 2 objects in hash map but keys of 2 values are same. even implemented hashcode and equals method. but still it is showing 2 values instead of 3.</p>
  
  <p>code:</p>
  
  <pre><code>package test1;
  
  import java.util.HashMap;
  
  public class HashMapDemo {
  
      int i;
      String abc;
      HashMapDemo(int a,String b){
          i=a;
          abc=b;
      }
      public String toString(){
          return i +abc;
      }
  
      public static void main(String[] args){
          HashMapDemo obj1= new HashMapDemo(2,"hello");
          HashMapDemo obj2= new HashMapDemo(3,"world");
          HashMapDemo obj3= new HashMapDemo(4,"around");
          toDos t1=new toDos("aa");
          toDos t2=new toDos("bb");
          toDos t3=new toDos("aa");
          HashMap test=new HashMap();
          test.put(t1,obj1);
          test.put(t2, obj2);
          test.put(t3,obj3);
          System.out.println(test.size()+""+test.get(obj2)+test);
  
      }
  }
  </code></pre>
  
  <p>Code for keys:</p>
  
  <pre><code>package test1;
  
  import java.util.HashMap;
  
  class toDos
   {
  
          String a;
      toDos(String b){
          a=b;
      }
      public boolean equals(Object obj){
          System.out.println("call of equals");
          if((toDos)obj instanceof toDos &amp; (toDos)obj !=null){
              toDos temp = (toDos) obj;
              if(temp.a.equals(this.a)){
                  return true;
              }
          }
          return false;
  
      }
      public int hashCode(){
          System.out.println("call of hasCode");
          return (a!=null)? a.hashCode():0;
      }
  
      public String toString(){
          return a;
      }   
  }
  </code></pre>