Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Java Vector Java ArrayList Difference

Difference between Java Vector and Java ArrayList

ArrayList and Vector are very similar to each other. Difference between ArrayList and Vector is as given below

1) ArrayList is not synchronized, while Vector is synchronized.
Vector is synchronized, so its thread safe, ArrayList is not thread safe. So if multiple threads are supposed to manipulate the contents of the list, Vector should be used instead of the ArrayList.

On the other hand, synchronization causes the performance penalty. So if thread safe collection is not needed then ArrayList should be used instead of the Vector.

2) ArrayList and Vector both are resizable array, and internally uses the array to hold elements of the list. Capacity of the ArrayList or Vector is the actual size of the array used to store the list elements. Capacity of the ArrayList or Vector grows automatically as we add elements to it. By default Vector doubles the capacity when needed, while ArrayList increases the capacity by half.
Your rating: None Average: 4 (1 vote)
Share this

Post new comment