Why initialize HashSet<>(0) to zero?

前端 未结 5 1150
半阙折子戏
半阙折子戏 2021-02-07 02:50

I love a HashSet<>() and use this eagerly while initializing this with the default constructor:

Set users = new HashSet<>();
         


        
5条回答
  •  暖寄归人
    2021-02-07 03:51

    The Initial Load factor of HashMap is 16. When HashMap holds data of 12 Records which is 75% of its initial size. then HashMap increases its size.

    So here we just set the initial capacity as 0 by passing it in Constructor.

提交回复
热议问题