i have some confusion about Hashing and Rehashing. below is my understanding please correct me if i am wrong.
as per picture, bucket is actually the array of Entry class which stores the element in the form of linked list. each new key-value pair, whose key has same hashcode of Entry Array bucket will be stored as a Entry Object in bucket which is storing that hashcode elements. if the key has new hashcode which is currently not present in the Entry Array bucket then a new bucket will be added with the respective hashcode.
now the question is , when actually rehashing occurs?
case 1: lets suppose i have Entry array having bucket of hashcode 1,2 3 with addition of new element at the time Entry Array Bucket reached 12 its OK , but as soon as a new element comes whose hashcode is 13( assuming i am adding element in series of hashcode 1 then 2 and so on), a new Map / Array of Entry Bucket( please clarify which one) will be created, and the new capacity will be 32, now the array of Entry can hold distinct 32 buckets.
case 2 : number of bucket dosent matter, default capacity of HashMap 16 means it can store 16 element in it , dosent matter in single bucket or anyhow. because of load factor .75, as soon as 13th element is added a new array of bucket will be created with 32 in it , ie now the total Entry node in all the link list can be 32.
i think case 2 is correct. please enplane the Re Hashing process, better if this diagram will be used.