The main difference between the
Vector
class and the ArrayList
class is the use of synchronization. Apart from two methods used only during serialization, none of the ArrayList
methods are synchronized; in contrast most of the Vector
methods are synchronized directly or indirectly. Consequently Vector
is thread-safe, and ArrayList
isn't. This makes ArrayList
faster than Vector
. For some of the latest JVMs the difference in speed between the two classes is negligible: strictly speaking, for these JVMs the difference in speed between the two classes is less than the variation in times obtained from tests comparing the performance of these classes.
1) Synchronization - ArrayList is not thread-safe whereas Vector is thread-safe. In Vector class each method like add(), get(int i) is surrounded with a synchronized block and thus making Vector class thread-safe.
2) Data growth - Internally, both the ArrayList and Vector hold onto their contents using an Array. When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.