Similarities and differences between Vector and ArrayList

Similarities between Vector and ArrayList

1. Both are classes in java.util package
2. Both ArrayList and Vector are implemented from java.util.Collection interface.
Both are based on dynamic arrays
3. Collections class static methods can be applied to both Vector and ArrayList
4. Both can store duplicates, and maintains insertion order of elements.

Differences between Vector and ArrayList

ArrayList is not Synchronized, by default Vector is synchronized
ArrayList implements methods of Collection interface Vector provides other legacy methods, in addition to methods of Collection interface
ArrayList is Faster, as it is not Synchronized Vector is slower, as it is Synchronized
ArrayList is not Legacy class. ArrayList is introduced along with Collection Framework, in Java 1.2 Vector is Legacy class, and exists since initial version of Java. In Java 1.2, Vector has been accommodated in Collection Framework, and its Legacy methods were preserved, as well
When no more room exists to store an added element, size is increased by half of current size In case of Vector size gets increased by the current size

Methods declared in Collection interface

You may also like to read:
When to use List or Set
What are Synchronized Collections

How to use HashSet, to store our own objects
What is Map?

One thought on “Similarities and differences between Vector and ArrayList”

Leave a Reply