title: Strange behavior of HashMap in Java
body: <p>I found some strange behavior for hashmap In below class.</p>
  
  <pre><code>class Employee {
  
    private String a;
    private int b;
  
    public Employee(String a, int b) {
      this.a = a;
      this.b = b;
    }
  
    @Override
    public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((a == null) ? 0 : a.hashCode());
      result = prime * result + b;
      return result;
    }
  
    @Override
    public boolean equals(Object obj) {
      if (this == obj)
          return true;
      if (obj == null)
          return false;
      if (getClass() != obj.getClass())
          return false;
      Employee other = (Employee) obj;
      if (a == null) {
          if (other.a != null)
              return false;
      } else if (!a.equals(other.a))
          return false;
      if (b != other.b)
          return false;
  
      return true;
    }
  
    public static void main(String[] args) {
      HashMap&lt;Employee,Integer&gt; map = new HashMap&lt;&gt;();
  
      for(int i = 0; i &lt; 13; i++) {
          map.put(new Employee( i + "", i), i + i);
      }
    }
  }
  </code></pre>
  
  <p>When i am using new Employee( "", i) as key for storing data in map, it is working fine and resizing the map after 12th node insert. but on using
  new Employee( i+"", i) as key, it is showing strange behavior, on adding 10th element by using this key, it resize map from 16 to 32 and on adding 11th element it is again resizing map from 32 to 64. 
  Please help if you found any reason for this behavior.</p>