One should normally use ArrayList - it offers better performance.
Vector is synchronized for concurrent modification. But Vector synchronizes on each individual operation. That’s almost never what one want to do.
Generally you want to synchronize a whole sequence of operations. Synchronizing individual operations is both less safe (if you iterate over a Vector, for instance, you still need to take out a lock to avoid anyone else changing the collection at the same time, which would cause a ConcurrentModificationException in the iterating thread) but also slower (why take out a lock repeatedly when once will be enough)?
There is always a overhead (CPU and Memory) of locking even when you don’t need to.
In almost all scenario’s you can utilize ArrayList in your application code, if you are looking for a synchronized version of List you can decorate a collection using the calls such as Collections.synchronizedList()
As for a Stack equivalent - you can have a look at Deque/ArrayDeque.
As a result, Vector is often considered deprecated nowadays.
Main Differences between two Classes
- Vector methods is synchronized, ArrayList is not
- Data Growth - Vector doubles its size when its full, ArrayList increases its size by 50% when its full.
- Vector class retrofitted to implement the List interface, making it a member of the Java Collections Framework in JDK 1.2