Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
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.

Post new comment