Load Factor



Ques) What is LoadFactor?

Rep) LoadFactor is useful to determine the point where the capacity of the Hashtable (HashMap) will be doubled For Hashtable initial capacity * loadfactory–>11 * 0.75=8

This class implements a hashtable, which maps keys to values. Any non-null object can be used as a key or as a value.To successfully store and retrieve objects from a Hashtable , the objects used as keys must implement the HashCode method and the equals method.

The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased. When the number of entries in the Hashtable exceeds the product of the load factor and the current capacity, the capacity is increased by calling the rehash method.
Therefore after starting 8th pair key values, the capacity of the Hashtable will be “Doubled” –>11*2=22.

Hashtable ht=new Hashtable(100);

|__ It is the inital capacity of the hashtable

Trackback URL

Post a Comment