Java Collection

What is the default capacity and load factor in Java Collection? Explain its role.

Questions by adesh.khare

Showing Answers 1 - 9 of 9 Answers

Sarje

  • Aug 20th, 2009
 

Default Capacity of any Collection say HashSet is 16. It means when you create a HashSet using its default constructor then first HashSet will be created to hold 16 elements  or you can say that memory space is allocated to hold 16 elements.

load factor

By default load factor is 0.75. It means when the 75% of the capacity will be filled and you add new element then capacity will be increased (most probably doubled).

For example 16 default capacity and 0.75 load factor till 12th element addition the capacity will remain 16 but when you add 13th element then first capacity will be increased to 32 and element will be added.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions