最近看一Hashtable的源代码,不懂。它的构造函数如下:Hashtable()
Constructs a new, empty hashtable with a default initial capacity (11) and load factor, which is 0.75. Hashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75. Hashtable(int initialCapacity, float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor. 想问的是,整数initialCapacity表示容量(默认11),那浮点数loadFactor是什么呢(默认0.75)?
而且,为什么整数要默认11,浮点要默认0.75???百思不解,而又没发现象我这样弱智的问题,所以请赐教。
Constructs a new, empty hashtable with a default initial capacity (11) and load factor, which is 0.75. Hashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75. Hashtable(int initialCapacity, float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor. 想问的是,整数initialCapacity表示容量(默认11),那浮点数loadFactor是什么呢(默认0.75)?
而且,为什么整数要默认11,浮点要默认0.75???百思不解,而又没发现象我这样弱智的问题,所以请赐教。
解决方案 »
- 谁告诉我这是用什么UML工具画的?
- Oracle数据库,JDBC访问,字段类型是DATE,PreparedStatement里用setTimestamp还是setDate?
- 关于Eclipes和NetBeans
- java 中线程 中的 lock(this) 这个this指的是什么呀?
- 如何让JUnit支持从XML中读取测试数据?
- 求Java数据结构和算法(第二版)电子版
- 求救!vc 客户端的socket 与 java服务器 通信失败。sos!!!
- 请教 JVM INSTR monitorenter ;是什么意思?
- 急!请问有分析java程序性能瓶颈的工具吗?例如,统计 java 程序中函数调用次数?
- 请问如何在oracle数据库中存取图片?
- 因为以前听过,但今天是认真试了一下goto break continue这三个语句.
- 生成tif图片文件
也就是初始化时buckets的数量,这个很好理解;
那浮点数loadFactor是什么呢(默认0.75),
它表示Hashtable所允许的饱和程度
(饱和程度过大的时候容易发生hash collision);
0.75表示Hashtable 75%的容量被装满后,
Hashtable的容量就会自动增加。英文版的更纯正些:
The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased. When the number of entries in the hashtable exceeds the product of the load factor and the current capacity, the capacity is increased by calling the rehash method.
但是为什么不等到用完了再扩充呢?冲突是说 出现相同的key值吗?那只要通过程序自动比较避免出现相同的key值就好了。
或者冲突是其他的意思??