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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between jfc & wfc?

591


What is a Null object?

887


What is the use of arraylist in java?

522


Is null keyword in java?

523


Is arraylist an object in java?

597






What are desktop procedures?

556


What is object data type?

560


what is aggregation in java?

584


Can we restart a thread already started in java?

580


What does void * mean?

529


2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?

1829


What is * argv?

700


What is application system?

501


What is the difference between and ?

504


What is a percentage sign called?

615