Advertisement

Udemy WW Udemy WW
Showing posts with label Collection. Show all posts
Showing posts with label Collection. Show all posts

Thursday, 19 January 2012

what is loadfactor in HashSet and HashMap


The load factor is a measure of how full the hash set is allowed to get before its capacity is automatically increased. When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets.
If you specify a capacity of 128 and a load factor of .75. The load factor  decide when it is time to double the size of the table, in this case, just after you have added 96 elements, not in deciding its initial size.
source:
http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html

Advertisement

Udemy WW