how to change the hashmap load factor

Viewed 3260

We know that hashmap has default load factor 0.75, and if I want to change it how to do that.

Is there any method so that we can set and use the load factory. I have 100k records and I don't want to rehashing again and again, I want to change the load factor so that it can work efficiently without rehashing.

3 Answers

It's done at the time of constructing map. You can set the load factor and initial capacity. Initial capacity is the initial number of buckets for hashing and load factor is the maximum allowed percentage of entries before resizing and auto-increment. you can set the value as float.

Related