HashMap(jdk8)

HashMap hashMap = new HashMap<>();
java.util.HashMap
	public HashMap(),给负载因子赋值为:0.75;
		this.loadFactor = DEFAULT_LOAD_FACTOR;

hashMap.put("hello1", "world1");
	putVal(int hash, K key, V value, boolean onlyIfAbsent,boolean evict)
		java.util.HashMap.resize()
			在resize()方法中,

Node[] newTab = (Node[])new Node[newCap]

 

底层Node(k,v)[]数组的长度n,与key的哈希值hash与key的哈希值无符号右移16位取与运算;;
n = table.length;
hash = (h = key.hashCode()) ^ (h >>> 16)
location = (n - 1) ^ hash

你可能感兴趣的:(java8)