What happens On HashMap in Java if the size of the HashMap exceeds a given threshold defined by load factor ?
- If the size of the Map exceeds a given threshold defined by load-factor e.g. if load factor is .75 it will act to re-size the map once it filled 75%.
- Similar to other collection classes like ArrayList, Java HashMap re-size itself by creating a new bucket array of size twice of previous size of HashMap , and then start putting every old element into that new bucket array.
- This process is called rehashing because it also applies hash function to find new bucket location.
No comments:
Post a Comment