标签:代码 size 面向 float hash表 分析 span static 接口
public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable { private static final long serialVersionUID = 362498820763181265L;
首先它是继承了AbstractMap,这个抽象类里面有很多方法,
从这个可以看出面向对象的特性,单继承,接口的多实现,
同时实现了序列号接口,可以进行网络传输,在进行网络传输的时候实体类一般都会实现序列号接口,以便传输,
在整合redis的时候,如果实体没有进行序列化,是无法传输进入到redis中的value上的
static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16
1 << 4
这个是位运算: 二进制为 1 向前唯一四位,那么就是10000 那么换成十进制就是2的4次方 就是16,所以hashmap的初始容量为16,
static final int MAXIMUM_CAPACITY = 1 << 30;
static final float DEFAULT_LOAD_FACTOR = 0.75f;
static final int TREEIFY_THRESHOLD = 8;
static final int UNTREEIFY_THRESHOLD = 6;
/**
* The smallest table capacity for which bins may be treeified.
* (Otherwise the table is resized if too many nodes in a bin.)
* Should be at least 4 * TREEIFY_THRESHOLD to avoid conflicts
* between resizing and treeification thresholds.
*/
static final int MIN_TREEIFY_CAPACITY = 64;
static final int hash(Object key) { int h; return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16); }
标签:代码 size 面向 float hash表 分析 span static 接口
原文地址:https://www.cnblogs.com/xiufengchen/p/10337825.html