public class Hashtable<K,V>
extends Dictionary<K,V>
implements Map<K,V>, Cloneable, java.io.Serializable { Hashtable的默认初始容量是11,加载因子是0.75f。通过synchronized方法保证线程安全。
实现结构与HashMap基本一致。Hashtable的键和值都不能为空。 Hashtable的构造函数:
     /**
* 使用指定的初始容量和装载因子构造一个空的Hashtable.
*
* @param initialCapacity hashtable的初始容量
* @param loadFactor hashtable的装载因子
* @exception IllegalArgumentException 如果初始容量小于0,或装载因子是负数,则抛出IllegalArgumentException异常
*/
public Hashtable(int initialCapacity, float loadFactor) {
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal Capacity: "+
initialCapacity);
if (loadFactor <= 0 || Float.isNaN(loadFactor))
throw new IllegalArgumentException("Illegal Load: "+loadFactor); if (initialCapacity==0)
initialCapacity = 1;
this.loadFactor = loadFactor;
table = new Entry<?,?>[initialCapacity];
threshold = (int)Math.min(initialCapacity * loadFactor, MAX_ARRAY_SIZE + 1);
} /**
* Constructs a new, empty hashtable with the specified initial capacity
* and default load factor (0.75).
*
* @param initialCapacity the initial capacity of the hashtable.
* @exception IllegalArgumentException if the initial capacity is less
* than zero.
*/
public Hashtable(int initialCapacity) {
this(initialCapacity, 0.75f);
} /**
* Constructs a new, empty hashtable with a default initial capacity (11)
* and load factor (0.75).
*/
public Hashtable() {
this(11, 0.75f);
} /**
* Constructs a new hashtable with the same mappings as the given
* Map. The hashtable is created with an initial capacity sufficient to
* hold the mappings in the given Map and a default load factor (0.75).
*
* @param t the map whose mappings are to be placed in this map.
* @throws NullPointerException if the specified map is null.
* @since 1.2
*/
public Hashtable(Map<? extends K, ? extends V> t) {
this(Math.max(2*t.size(), 11), 0.75f);
putAll(t);
}

最新文章

  1. Linux学习之文件操作
  2. 概率论与数理统计图解.tex
  3. Vue2随笔
  4. App.config/Web.config 中特殊字符的处理
  5. aehyok.com的成长之路一——开篇
  6. Ecplise + Xdebug 一波三折终于能单步调试了
  7. SAP B1 ADDON 开发
  8. Rapha&#235;l 是一个小型的 JavaScript 库,用来简化在页面上显示向量图的工作。你可以用它在页面上绘制各种图表、并进行图片的剪切、旋转等操作。
  9. yum -------包安装库
  10. 分分钟教你集成沉浸式侧滑关闭Activity
  11. [转]CentO下限制SSH登录次数
  12. C# this关键字
  13. 前端程序员应该知道的 15 个 jQuery 小技巧
  14. Redis-安装、启动
  15. Array.prototype鲜为人知的事实
  16. Spring揭秘 读书笔记 七 BeanFactory的启动分析
  17. python 爬虫之beautifulsoup(bs4)使用 --待完善
  18. 《Self-Attention Generative Adversarial Networks》里的注意力计算
  19. Eclipse导入hadoop源码
  20. fastjson转换json字符串key的首字母小写变大写的解决办法

热门文章

  1. &lt;Django&gt;一些小知识
  2. 8_InlineHook
  3. MySQL数据库之DDL(数据定义语言)
  4. CSIC_716_20191112【闭包函数和装饰器】
  5. python 基本常用数据类型
  6. 列表中的index,extend,count方法
  7. Windows 关闭win32 控制台
  8. 重装系统后配置原有的mysql
  9. layui弹框文件导入
  10. 微信sdk 隐藏右上角菜单项