Disclosure: This text could include affiliate hyperlinks. Whenever you buy, we could earn a small fee.
The final word aim is to familiarize your self with the distinguishing property of ArrayList and Vector. Java 5 additionally provides one other implementation of the Record interface which is analogous to Vector and ArrayList however supplies higher concurrency entry than Vector, it is known as CopyOnWriteArrayList.
By the way in which, that is the third article discussing the Assortment interview query, Distinction between LinkedList and ArrayList and Record vs Set are different widespread interview questions based mostly upon the gathering framework in Java.
1) Vector and ArrayList are index-based and backed up by an array internally.
2) Each ArrayList and Vector keep the insertion order of a component. This implies you’ll be able to assume that you’re going to get the item within the order you’ve got inserted in the event you iterate over ArrayList or Vector.
4) ArrayList and Vector additionally permits null and duplicates.
Vector vs ArrayList in Java
Now let’s examine some key variations between Vector and ArrayList in Java, this may resolve when is the best time to make use of Vector over ArrayList and vice-versa. Variations are based mostly upon properties like synchronization, thread-safety, pace, efficiency, navigation, and Iteration over Record, and so forth.
1) Synchronization and thread-safety
Alternatively, ArrayList strategies should not synchronized thus not appropriate to be used in a multi-threaded atmosphere. That is additionally a widespread interview query on a thread, the place individuals ask why ArrayList can’t be shared between a number of threads.
2) Pace and Efficiency
3) Capability
Each time Vector crossed the brink specified it will increase itself by the worth laid out in capacityIncrement subject when you can improve the dimensions of ArrayList by calling ensureCapacity () technique.
4) Enumeration and Iterator
5) Legacy
One other level value remembering is Vector is a type of lessons which comes with JDK 1.0 and was initially not a part of the Assortment framework however within the later model, it has been re-factored to implement the Record interface in order that it might turn out to be a part of the gathering framework
And, here’s a good desk to know the distinction between ArrayList and Vector class in Java:

Different Java tutorials from Javarevisited