/**
* Returns a power of two size for the given target capacity.
*/staticfinalinttableSizeFor(int cap){
int n = cap -1;
n |= n >>>1;
n |= n >>>2;
n |= n >>>4;
n |= n >>>8;
n |= n >>>16;return(n <
JDK8 HashMap容量计算算法分析1.源码/** * Returns a power of two size for the given target capacity. */static final int tableSizeFor(int cap) { int n = cap - 1; n |= n >>> 1; n |= n >>> 2; n |= n >>> 4;