GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  
 Java  |  Question 928 of 928    Print  
Java Collection
What is the default capacity and load factor in Java Collection? Explain its role.


  
Total Answers and Comments: 3 Last Update: August 20, 2009     Asked by: adesh.khare 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Sarje
 
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.

Above answer was rated as good by the following members:
nagaraju302, mshusain, chief3rd
August 13, 2009 09:41:30   #1  
jonghun95 Member Since: August 2009   Contribution: 1    

RE: Java Collection
Initial capacity is 16 and load factor is 0.75f
 
Is this answer useful? Yes | No
August 13, 2009 21:45:34   #2  
myogeshchavan97 Member Since: December 2008   Contribution: 28    

RE: Java Collection
The Default Capacity is 16 and Load Factor is 0.75
 
Is this answer useful? Yes | No
August 20, 2009 04:19:29   #3  
Sarje Member Since: August 2009   Contribution: 62    

RE: Java Collection
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.

 
Is this answer useful? Yes | NoAnswer is useful 3   Answer is not useful 0Overall Rating: +3    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape