这三者都可以随机访问,也就是支持通过索引查找数据。 都是有序(可以实现元素怎么进怎么出)

Vector和ArrayList比较

相同之处

1 它们都是List

它们都继承于AbstractList,并且实现List接口。

3 它们都是通过数组实现的,本质上都是动态数组

4 它们的默认数组容量是10

不同之处

1 线程安全性不一样

ArrayList是非线程安全;
   而Vector是线程安全的,它的函数都是synchronized的,即都是支持同步的。
   ArrayList适用于单线程,Vector适用于多线程。

2 对序列化支持不同

ArrayList支持序列化,而Vector不支持;即ArrayList有实现java.io.Serializable接口,而Vector没有实现该接口。

3 虽然默认容量都是10,但是Vector在构造函数中就初始化数组了,ArrayList是在add方法中,第一次添加元素时才初始化数组。

4 容量增加方式不同

逐个添加元素时,若ArrayList容量不足时,“新的容量”=“原始容量x3/2 ”。
   而Vector的容量增长与“增长系数有关”,若指定了“增长系数”,且“增长系数有效(即,大于0)”;那么,每次容量不足时,“新的容量”=“原始容量+增长系数”。若增长系数无效(即,小于/等于0),则“新的容量”=“原始容量 x 2”。

ArrayList和LinkedList比较

相同:

1.它们都是List,可以通过索引访问。

2.有序(可以实现怎么进怎么出)

不同:

1.底层实现不同:ArrayList是数组,LinkedList是双向链表

2.ArrayList要扩容,linkedlist不用

Vector 、ArrayList、LinkedList比较的更多相关文章

  1. Hashtable,HashMap,TreeMap有什么区别?Vector,ArrayList,LinkedList有什么区别?int和Integer有什么区别?

    接着上篇继续更新. /*请尊重作者劳动成果,转载请标明原文链接:*/ /*https://www.cnblogs.com/jpcflyer/p/10759447.html* / 题目一:Hashtab ...

  2. 09 Collection,Iterator,List,listIterator,Vector,ArrayList,LinkedList,泛型,增强for,可变参数,HashSet,LinkedHashSet,TreeSet

    09 Collection,Iterator,List,listIterator,Vector,ArrayList,LinkedList,泛型,增强for,可变参数,HashSet,LinkedHas ...

  3. java面试题(杨晓峰)---第八讲谈谈Vector,ArrayList,LinkedList有何区别?

    Vector,ArrayList,LinkedList均为线性的数据结构,但是从现实方式与应用场景中又存在差别. 1 底层实现方式 ArrayList内部数组来实现,LinkedList内部采用双向链 ...

  4. vector,arraylist, linkedlist的区别是什么

    LinkedList类 LinkedList实现了List接口,允许null元素. 此外LinkedList提供额外的get,remove,insert方法在LinkedList的首部或尾部. Lin ...

  5. Vector,ArrayList, LinkedList的区别

    1.Vector.ArrayList都是以类似数组的形式存储在内存中,LinkedList则以链表的形式进行存储. 2.List中的元素有序.允许有重复的元素,Set中的元素无序.不允许有重复元素. ...

  6. Vector ArrayList LinkedList

    三者都实现了List接口! Vector与ArrayList:采用顺序存储的方式,但是Vector是线程安全的,ArrayList是线程不安全的,按需使用: 当存储空间不足的时候,ArrayList默 ...

  7. ArrayList、Vector、LinkedList的区别联系?

    1.ArrayList.Vector.LinkedList类都是java.util包中,均为可伸缩数组. 2.ArrayList和Vector底层都是数组实现的,所以,索引数据快,删除.插入数据慢. ...

  8. ArrayList、Vector、LinkedList源码

    List接口的一些列实现中,最常用最重要的就是这三个:ArrayList.Vector.LinkedList.这里我就基于JDK1.7来看一下源码. public class ArrayList< ...

  9. ArrayList、Vector、LinkedList的区别及其优缺点? (转载)

    原文链接:http://blog.csdn.net/wangzff/article/details/7296648 ArrayList,LinkedList,Vestor这三个类都实现了java.ut ...

  10. ArrayList LinkedList Vector

    ArrayList是基于数组实现的,没有容量的限制. 在删除元素的时候,并不会减少数组的容量大小,可以调用ArrayList的trimeToSize()来缩小数组的容量. ArrayList, Lin ...

随机推荐

  1. mysql升级到5.7时间戳报错

    往数据库里创建新表的时候报错: [Err] 1067 - Invalid default value for 'updateTime' DROP TABLE IF EXISTS `passwd_res ...

  2. postgresql中的各种scan的比较

    最近在看postgresql的查询计划,在查询中对表的扫描计划大概有如下几种: Seq Scan Index Scan Bitmap Heap Scan Index Only Scan 这里就把自己的 ...

  3. Django template的html明明改了,前端页面居然没有对应变化?!---Django的小坑

    写django的时候,我有个模板的名字叫detail.html,被detail视图函数渲染 因为那个detail写乱了,但是里面有东西要参考,我没删掉它,改名为detail_old.html,又在目录 ...

  4. Unity---动画系统学习(1)---在状态机中简单控制物体运动

    1. 介绍 新建一个GameObject-Cube,在Window下添加Animation(快捷键ctrl+6).会添加用于播放动画的三个东西.物体上的Animator组件.Animator Cont ...

  5. vue模拟后台数据,请求本地数据的配置(旧版本dev-server.js,新版本webpack.dev.conf.js)

    最近学习一个vue-cli的项目,需要与后台进行数据交互,这里使用本地json数据来模仿后台数据交互流程.然而发现build文件夹下没有dev-server.js文件了,因为新版本的vue-webpa ...

  6. 洛谷 P2495 [SDOI2011]消耗战(虚树,dp)

    题面 洛谷 题解 虚树+dp 关于虚树 了解一下 具体实现 inline void insert(int x) { if (top == 1) {s[++top] = x; return ;} int ...

  7. 119th LeetCode Weekly Contest K Closest Points to Origin

    We have a list of points on the plane.  Find the K closest points to the origin (0, 0). (Here, the d ...

  8. 118th LeetCode Weekly Contest Pancake Sorting

    Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, t ...

  9. matlab实用教程

    苏金明.2005.电子工业     1 语句末尾加 : 可以不显示到屏. who 查看变量 whos 列出变量信息 exist t 判断变量是否在空间中. help 函数 doc 函数 : doc f ...

  10. js面向切面编程

    Function.prototype.before=function(func){ var _self=this; return function(){  if(func.apply(this,arg ...