HashSet load factor

前端 未结 3 1251
Happy的楠姐
Happy的楠姐 2021-02-04 03:34

If I use a HashSet with a initial capacity of 10 and a load factor of 0.5 then every 5 elements added the HashSet will be increased or first the

3条回答
  •  盖世英雄少女心
    2021-02-04 03:53

    Default initial capacity of the HashMap takes is 16 and load factor is 0.75f (i.e 75% of current map size). The load factor represents at what level the HashMap capacity should be doubled.

    For example product of capacity and load factor as 16 * 0.75 = 12. This represents that after storing the 12th key – value pair into the HashMap , its capacity becomes 32.

提交回复
热议问题