Java doc says - When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed
In below program -
HashMap<Integer, String> map = new HashMap<Integer, String>();
int i = 1;
while(i<16) {
map.put(i, new Integer(i).toString());
i++;
}
Key is of type Integer, at insertion of 13th to 15th element HashMap capacity remains as 16 and threshold remains same as 12, why ?
Debug screenshot after adding 13th element in map -
args String[0] (id=16)
map HashMap<K,V> (id=19)
entrySet null
hashSeed 0
KeySet null
loadFactor 0.75
modCount 13
size 13
table HashMap$Entry<K,V>[16] (id=25)
threshold 12
values null
i 14
[null, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9, 10=10, 11=11, 12=12, 13=13, null, null]
HashMap with key of type String - HashMap<String, String>
or a custom class - Map<Employee,Integer>
show expected behaviour at 13th insertion