Woodstock Blog

a tech blog for general algorithmic interview questions

[Java OOP] Java Vector and ArrayList

Difference

  1. Vectors are synchronized, ArrayLists are not.

  2. Data Growth Methods

    A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.

Similarities

  1. Both Vector and ArrayList use growable array data structure.

  2. They both are ordered collection classes as they maintain the elements insertion order.

  3. Vector & ArrayList both allows duplicate and null values.

  4. They both grows and shrinks automatically when overflow and deletion happens.

source

History

The vector was not the part of collection framework - it has been included in collections later. It can be considered as Legacy code.

There is nothing about Vector which List collection cannot do. Therefore Vector should be avoided. If there is a need of thread-safe operation, make ArrayList synchronized.