Vector is legacy class which is available with Java before collection framework comes into picture while ArrayList was introduce with collection framework. There are some basic differences between ArrayList and Vector as well as few similarities. It is very common to ask question around ArrayList and Vector in interviews. Also if we know the differences and similarities between ArrayList and Vector, it will be easier for us to select one of these while writing our code.
Differences between ArrayList and Vector.[table “” not found /]
Similarities between ArrayList and Vector.
- Both ArrayList and Vector are derived from AbstractList and implements List interface, which means both of them are ordered collection and allows duplicates.
- ArrayList and Vector are index based Collection and we can use get(index) method to retrieve objects.
Other Interview questions.