ArrayList vs Vector: Difference and Comparison

ArrayList and vectors store elements of the array. They allow the users to store multiple objects. Data is stored dynamically in both of them.

Key Takeaways

  1. ArrayList and Vector are resizable array implementations in Java.
  2. Vector is synchronized, but ArrayList is not.
  3. ArrayList is faster. The Vector is thread-safe.

ArrayList vs Vector

ArrayList is a resizable array that is not synchronized, which makes it fast. It uses the Iterator interface to traverse the elements. Vector stores elements of the same type or converts implicitly and can use both the Iterator and enumeration interface. It is synchronized and hence slow.

ArrayList vs Vector

IT Quiz

Test your knowledge about topics related to technology

1 / 10

What is the radix of the octal number system?

2 / 10

For which of the following Android is mainly developed?

3 / 10

Firewall in computer is used for

4 / 10

'.BAK' extension usually refers to what kind of file?

5 / 10

Which of the following AI domain attempts to extract information from spoken and written words using algorithms?

6 / 10

Who founded Apple Computers?

7 / 10

LED stands for:

8 / 10

Which of the following semiconductor is mostly used to construct electronic circuits?

9 / 10

Android is -

10 / 10

Which number system has a base 16

Your score is


ArrayList helps the user to make modifications to the size of the array. ArrayList makes the array shrink or expand based on the user’s requirement.

Vector is found in Java. Util package. It supports a dynamic array of elements which means the array is resizable. Vectors belong to the legacy class.

Comparison Table

Parameters of ComparisonArrayListVector
SynchronizationArrayList is not Synchronized i.e., it could work on various threads simultaneously.Vector is synchronized i.e., only one thread could handle the code at a moment.
SpeedIts operations are fast as they are non-synchronized.Vector operations run slower as they are synchronized.
ResizingIf elements exceed their capacity then ArrayList increases 50% of the existing array size.If elements exceed their capacity then the vector increases 100% of the existing array size.
PreferenceProgrammers prefer ArrayList over vectors.It is less preferred as synchronization in vectors causes inferior performance.
Traversal(pass-through)It uses Iterator to traverse the elements.It can use the Iterator as well as enumeration to traverse the elements.

What is an ArrayList?

ArrayList is a modifiable array. It is found in java. util package. The creation of an ArrayList is helpful when the user does not know the size of the data to be included.

ArrayList lets the users perform the basic operations of adding elements, removing elements, changing elements, and loop operations. 

ArrayList supports multiple operations. 

  1. To add elements: Use add() operation to add elements.
  2. To access any element: Elements can be accessed using the get() option. Elements are accessed using an indexer, which starts from zero. 
  3. To change an element: To make changes in any specific element, use the set() operation.
  4. To remove elements: These three operations Remove(), Removerange( , ), and RemoveAt, are used to remove elements in the ArrayList.

ArrayList is operated by its size. However, it can be expanded by adding the elements and shrank by removing the elements.

The following two methods are used to check whether an element exists in the Java ArrayList or not.

  1. contains()
  2. indexOf()

What is a Vector?

Vector is considered to be a legacy class that is synchronized. If multiple threads are needed to operate, then no two threads can perform simultaneously.

Vectors are considered to be thread-safe. Thread safety ensures the users that all threads function appropriately and satisfy their design criteria without unwanted interaction. 

Vector ensures the addition or deletion of elements by expanding or shrinking the size of the vector. There may be some cases where the user does not have prior knowledge regarding the length of an array.

Vector, just like ArrayList, lets the users perform the basic operations of adding elements, removing elements, changing elements, and loop operations.

  1. To add elements: Use add() operation to add elements.
  2. To change elements: Use the set() operation to change elements. Elements in vectors are attributed by their index.
  1. To remove elements: Use the remove() method to remove elements from the vector.

Vector supports other simplex operations apart from the basic stated operations.

Main Differences Between ArrayList And Vector

  1. ArrayList operations are not thread-safe, whereas vector operations are thread-safe.
  2. ArrayList is a collection class, whereas vector is a legacy class.

Last Updated : 19 July, 2023

dot 1
One request?

I’ve put so much effort writing this blog post to provide value to you. It’ll be very helpful for me, if you consider sharing it on social media or with your friends/family. SHARING IS ♥️

Leave a Comment

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

Want to save this article for later? Click the heart in the bottom right corner to save to your own articles box!