HashMap
HashMap 它是可以容器有空值的,这是它的一个非常重要的特点,另外就是它跟 HashTable 有一个区别,它可以有空值,而且它是同步的,其他的是跟 HashTable 是类似的
HashMap 构造方法
HashMap 默认初始容量和最大容量
shell
public HashMap(int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
}HashMap 构造方法
shell
public HashMap() {
this.loadFactor = DEFAULT_LOAD_FACTOR; // all other fields defaulted
}HashMap 核心方法
put 方法
put 方法,这个 HashMap 这里面的一个核心,用来给 HashMap 添加数据
shell
public V put(K key, V value) {
return putVal(hash(key), key, value, false, true);
}
朔风