Default initial capacity of hashtable
What is the default initial capacity of a hashtable? How can I get the capacity and load factor of hash table?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Suthish NairRank #92 · 22.8K reputationPosted Feb 24, 2011, 12:33 AM EST
Default initial capacity of a hashtable is zero.
Default load factor of a hashtable is 1.0.
Do an msdn search for more informations.
Soft CornerRank #1,221 · 1.5K reputationPosted Feb 24, 2011, 12:37 AM EST
The data type of Hashtable is object and the default size of a Hashtable is 0.
Hashtable h = new Hashtable( 149 /* capacity */, 0.75f /* loadfactor */ );
This constructor creates a Hashtable with the given capacity and load factor.
The initial capacity is not the number of elements you plan to put in the table. If you specified a capacity of 101 and a load factor of .75f, then the initial table could hold only 75 elements, before it had to grow. This means you must specify plenty of slop in your capacity setting. If you used a load factor of 1.0, your performance would be slow because you would have many collisions rather than direct lookups.
Suthish NairRank #92 · 22.8K reputationPosted Feb 27, 2011, 7:06 AM EST