ArrayList vs Vector

Posted on Updated on

Vector is legacy class which is available with Java before collection framework comes into picture while ArrayList was introduce with collection framework. There are some basic differences between ArrayList and Vector as well as few similarities. It is very common to ask question around ArrayList and Vector in interviews. Also if we know the differences and similarities between ArrayList and Vector, it will be easier for us to select one of these while writing our code.

Differences between ArrayList and Vector.

ArrayList Vector
ArrayList object is not synchronized by default. Vector object is synchronized by default.
In case of single thread, using ArrayList is faster than the Vector. In case of multiple thread, using Vector is advisable. With a single thread, Vector become slow.
ArrayList increases its size every time to 50 percent. Vector increases its size every time by doubling it.
ArrayList can use only Iterator to access the elements. Vector list can use Iterator and Enumeration.

Similarities between ArrayList and Vector.

  1. Both ArrayList and Vector are derived from AbstractList and implements List interface, which means both of them are ordered collection and allows duplicates.
  2. ArrayList and Vector are index based Collection and we can use get(index) method to retrieve objects.
You can find more about ArrayList here and Vector here.

Other Interview questions.


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.