The way a hashmap computes the index is the following code -
static int indexFor(int h, int length) {
return h & (length-1);
}
Now assuming a key is used for a second time (lets say another put) and at that time the length has changed. In such a case how does indexFor
return same index when length was 16 vs when length was 64 ?