I understand that when we declare a map like the following:
Map <String, Integer> map = new HashMap ();
The default load factor is 0.75 and its size is 16, when the buckets of the map exceed the number of 12 elements, the size changes to 32.
However, the way in which the map chooses the index of the bucket where the object will be placed when using the put function, is defined by hascode % n
but what happens when the map size exceeds the load factor? n no longer has the same value, therefore, how can you find the previously set entries if, when applying hascode % n
, the resulting index will not be the same as before?
My final question is :
how can the index of the bucket be the same after we've increased the size?