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 
jdk document says: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.

解决方案 »

  1.   

    rehash是什么意思?
    这两段我都看过,都没有说清楚load factor是什么东东?
      

  2.   

    load factor is actually a concept from B tree or databases. Let's take .75 as an example. If a node can hold 100 items, when it reaches 76 items, it will split into two nodes. And at this time, if its parent has 76 items, then the parent will split.rehash means re-organize. It happens when inserting and deleting. It is expensive so you want to avaid it as much as possible.