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;





相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2021-11-12
  • 2021-07-23
  • 2022-12-23
  • 2021-08-16
猜你喜欢
  • 2021-12-20
  • 2021-09-16
  • 2022-12-23
  • 2021-12-16
相关资源
相似解决方案