gpt4 book ai didi

java - 初始化期间如何确定 HashMap 负载因子?

转载 作者:行者123 更新时间:2023-12-01 11:25:42 25 4
gpt4 key购买 nike

初始化 HashMap 时,会创建 16 个槽。一开始它们都是空的。负载因子是占用的元素数量与 HashMap 大小的比率。那么默认或初始负载因子必须为 0,对吗?但是在引用 deitel 和 deitel 的 java 书籍时,它说默认负载因子是 0.75。这怎么可能?

最佳答案

来自javadoc

The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased.

这是一个阈值。

关于java - 初始化期间如何确定 HashMap 负载因子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30820708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com