美文网首页
Java中Arraylist容器与Vector容器的比较

Java中Arraylist容器与Vector容器的比较

作者: 铜雀春深锁不住 | 来源:发表于2017-07-04 11:03 被阅读0次

1.Arraylist and Vector implement the interface List.

2.the List interface extends the Collection object.

3. Vector is security in multhread,but arraylist not.

4.what is their bottom implemention,it is Array.

we can see what is array:

5: The construct method of arraylist

     public ArrayList(int initialCapacity)//指定初始容量

     public ArrayList()//容量为10

     public ArrayList(Collection c) //包含collection元素的array

6: the construct method of vector

   public Vector()//使用指定的初始容量和等于零的容量增量构造一个空向量。

   public Vector(int initialCapacity)//构造一个空向量,使其内部数据数组的大小,其标准容量增量为零。

   public Vector(Collection c)//构造一个包含指定 collection 中的元素的向量

   public Vector(int initialCapacity,int capacityIncrement)//使用指定的初始容量和容量增量构造一个空的向量

7:Adds the specified component to the end of this vector, increasing its size by one

   publicsynchronizedvoidaddElement(E obj){

        modCount++;

        ensureCapacityHelper(elementCount+1);

        elementData[elementCount++]=obj;

 }

相关文章

网友评论

      本文标题:Java中Arraylist容器与Vector容器的比较

      本文链接:https://www.haomeiwen.com/subject/ebvthxtx.html