In HashMap why threshold value (The next size value at which to resize) is capacity * load factor. Why not as equal to size or capacity of map

前端 未结 4 779
悲&欢浪女
悲&欢浪女 2021-02-05 22:59

In HashMap why threshold value (The next size value at which to resize) is capacity * load factor. Why not as equal to size or capacity

4条回答
  •  心在旅途
    2021-02-05 23:55

    In java 8 when threshold is reached, than content of bucket is swithcing from using links between object to balanced tree which improves performance from O(n) to O(log n). This is one of features in java 8 sometimes need to remember

提交回复
热议问题