1.

Differentiate between the Vector and ArrayList collections in Java.

Answer»

ArrayList and Vector collection classes both implement the List interface and are derived from AbstractList. Both these classes are index-based, meaning objects can be retrieved from the collection based on the index using the get(index) method.

CategoryVectorArrayList
SynchronizationVector is synchronized and thread-safe by default. This means that the internal state of the Vector is not compromised even if multiple threads are operating on it.ArrayList is neither thread-safe nor synchronized.
SpeedSince Vector is synchronized, it works relatively slower than ArrayList.ArrayList is faster than Vector because there is no overhead of maintaining synchronization.



Discussion

No Comment Found