ArrayList,HashSet,Vector等扩容数量

   ArrayList :

 默认大小: private static final int DEFAULT_CAPACITY = 10;

扩容后数量:int newCapacity = oldCapacity + (oldCapacity >> 1);  加上原来的一半

HashMap:
默认大小:static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; 16
扩容后数量:newCap = oldCap << 1 原来的两倍

HashTable
默认大小:11
public Hashtable() {
this(11, 0.75f);
}
扩容:
int newCapacity = (oldCapacity << 1) + 1;


Vector
默认大小:
public Vector() {
this(10); //默认大小为10
}
扩容后数量:
int newCapacity = oldCapacity + ((capacityIncrement > 0) ?
capacityIncrement : oldCapacity);
新建的时候如果没有指定capacityIncrement的大小,则默认未0,则每次增长为原来的两倍

ConcurrentHashMap
默认大小:private static final int DEFAULT_CAPACITY = 16;





posted @ 2020-03-05 17:21  开顺  阅读(297)  评论(0编辑  收藏  举报