相同点:
- 都继承于AbstractList,并且实现List接口
- 都实现了RandomAccess和Cloneable接口
- 默认数组容量是10个
- 都支持Iterator遍历
不同点:
而Vector是线程安全的,它的函数都是synchronized的,即都是支持同步的
ArrayList实现了java.io.Serializable接口
容量不足时,“ArrayList新的容量”=“(原始容量x3)/2
+ 1”“Vector新的容量”=“原始容量 x 2”
Vector采用v.indexOf(o, index);ArrayList采用indexOf(o);如下所示:
Vector v =new Vector(5);
v.indexOf(o, index);
ArrayList arraylist = new ArrayList();
arraylist.indexOf(o);
笔者水平有限,欢迎补充指正!
参考文献
http://www.jb51.net/article/42767.htm JAVA
LinkedList和ArrayList的使用及性能分析
JAVA Vector和ArrayList使用及性能比较
原文:http://blog.csdn.net/langjian2012/article/details/45040189