Let's move on to more detailed information. How will hashmap initialize bucket size?
following code from HashMap.java
while (i <paramInt) i <= 1;
If you pass the initial 10, then the code above is used to create power 2. Therefore, using the HashMap code above, initialize the bucket size 16;
And below code is used to calculate bucket index,
static int indexFor(int h, int length) { return h & (length - 1); }
source share