Easy learning with example program codes

what is the difference between arraylist and vector in java?


ArrayList class extends AbstractList and implements the List interface. It uses dynamic arrays for storing elements. It maintains insertion order. ArrayList can contain duplicate elements. It is not synchronized.

Note: ArrayList provides the facility of random access because of it is index based.


The java.util.Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created. It extends AbstractList and implements List interfaces.

ArrayList Vector
It is not synchronized. It is synchronized.
It is not a legacy class. It is a legacy class.
It increases its size by 50% of the array size. It increases its size by doubling the array size.


Java interview questions on collections

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki