what happens when we add the objects morethan the size limit
to a hashmap



what happens when we add the objects morethan the size limit to a hashmap..

Answer / kanu butani

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.
As a general rule, the default load factor (.75) offers a
good tradeoff between time and space costs. Higher values
decrease the space overhead but increase the lookup cost
(reflected in most of the operations of the HashMap class,
including get and put). The expected number of entries in
the map and its load factor should be taken into account
when setting its initial capacity, so as to minimize the
number of rehash operations. If the initial capacity is
greater than the maximum number of entries divided by the
load factor, no rehash operations will ever occur.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

Nullpointer exception is a very common exception. Why is it not made as a checked exception?

2 Answers   Ness Technologies,


What is treemap in java?

0 Answers  


Can constructor return value?

0 Answers  


Why object class is super class for every class in java?

0 Answers  


What is appletviewer?

0 Answers  






What is a parameter in a function?

0 Answers  


Is alive method in java?

0 Answers  


What is oops in java?

0 Answers  


What is super in java?

0 Answers  


Does garbage collection occur in permanent generation space in jvm?

0 Answers  


What is a thin-client application?

5 Answers   Adobe,


what is overloading in java?

13 Answers   Ascent, DNS, Infosys, SDA, VelTech,


Categories