JAVA Vector和ArrayList使用及性能比较

 

相同点:


  • 继承于AbstractList,并且实现List接口
  • 都实现了RandomAccess和Cloneable接口
  • 默认数组容量是10个
  • 都支持Iterator遍历

不同点:

  • ArrayList是非线程安全;
 而Vector是线程安全的,它的函数都是synchronized的,即都是支持同步的
  • 序列化支持不同:
ArrayList实现了java.io.Serializable接口
  • 容量增加数量不同:
容量不足时,“ ArrayList 新的容量”=“(原始容量x3)/2 + 1”“ Vector 新的容量”=“原始容量 x 2”
  • index方式不同:
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基础问题)