• Post Reply Bookmark Topic Watch Topic
  • New Topic

what initialCapacity and loadFactor do?  RSS feed

 
salih ayan
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what initialCapacity and loadFactor do? How effect performance of LinkedHashMap?
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is answered in the Javadoc for HashMap and LinkedHashMap. What specifically about that do you not understand ?
 
salih ayan
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stuart A. Burkett wrote:Your question is answered in the Javadoc for HashMap and LinkedHashMap. What specifically about that do you not understand ?


thanks for your answer . l got the point of what initialCapacity and loadFactor do . But still l couldnt get the How should we set the this two method parameter to increase performance of LinkedHashMap?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
salih ayan wrote:How should we set the this two method parameter to increase performance of LinkedHashMap?


Mostly, you don't. Only if you know for sure ahead of time (really, really know, and can back it up), or if you've observed performance or memory problems, should you tweak those values, and test the results.

I've been using Java for about 15 years, and I don't think I've ever needed to mess with those parameters, even back when HashMap was first introduced and JVMs were still fairly bad at CPU and memory use.

 
drac yang
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe it's a little bit complex process to prove 0.75 of load factor is the most efficient one.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not say in the API that anybody has proven that 75% is the best load factor. It describes it as a good compromise.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!