## Vector源码分析 原

Vincent-Duan

``````import java.util.List;
import java.util.Vector;

public class VectorTest {
public static void main(String[] args) {
List<String> vector = new Vector<>();
}
}``````

``````/**
* Constructs an empty vector so that its internal data array
* has size {@code 10} and its standard capacity increment is
* zero.
*/
public Vector() {
this(10);
}``````

``````/**
* Constructs an empty vector with the specified initial capacity and
* with its capacity increment equal to zero.
*
* @param   initialCapacity   the initial capacity of the vector
* @throws IllegalArgumentException if the specified initial capacity
*         is negative
*/
public Vector(int initialCapacity) {
this(initialCapacity, 0);
}``````

``````/**
* Constructs an empty vector with the specified initial capacity and
* capacity increment.
*
* @param   initialCapacity     the initial capacity of the vector
* @param   capacityIncrement   the amount by which the capacity is
*                              increased when the vector overflows
* @throws IllegalArgumentException if the specified initial capacity
*         is negative
*/
public Vector(int initialCapacity, int capacityIncrement) {
super();
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal Capacity: "+
initialCapacity);
this.elementData = new Object[initialCapacity];
this.capacityIncrement = capacityIncrement;
}``````

``````/**
* The array buffer into which the components of the vector are
* stored. The capacity of the vector is the length of this array buffer,
* and is at least large enough to contain all the vector's elements.
*
* <p>Any array elements following the last element in the Vector are null.
*
* @serial
*/
protected Object[] elementData;``````

Vector和ArrayList底层数据结构都是数组。

### Vincent-Duan

2015/03/16
21
0
Java 集合Vector源码深入解析

SIHAIloveYAN
2018/05/16
0
0
Java同步容器_Vector

Java同步容器_Vector Vector的API 可以看到Vector中很多方法都是同步的。 Vector的数据结构和ArrayList差不多，它包含了3个成员变量：elementData , elementCount， capacityIncrement。 (0...

2014/08/07
167
0

java面试中经常被问到list常用的类以及内部实现机制，平时开发也经常用到list集合类，因此做一个源码级别的分析和比较之间的差异。 首先看一下List接口的的继承关系： list接口继承Collectio...

2016/03/13
0
0
Java集合-08之 再看 List

0.概要 之前已经了解了的全部内容(ArrayList, LinkedList, Vector, Stack)。 接下来再看 第1部分 List概括 先回顾一下List的框架图 List 是一个接口，它继承于Collection的接口。它代表着有序...

xidiancoder
2017/09/04
0
0

jquery--DOM操作基础

6分钟前
0
0
Django的ChoiceField和MultipleChoiceField错误提示，选择一个有效的选项

24分钟前
1
0
Vue核心概念及特性 (一)

Vue (读音 /vjuː/，类似于 view) 是一套用于构建用户界面的渐进式框架。 > 特点: 易用，灵活，高效，渐进式框架。 > 可以随意组合需要用到的模块 vue + components + vue-router + vuex + v...

27分钟前
1
0
Kylin 精确去重在用户行为分析中的妙用

ApacheKylin

6
0

Pole丶逐

4
0