Difference between Arraylist and Vector in java

Parameter ArrayList Vector
1)Synchronized ArrayList is not Synchronized Vector is Synchronized
2)Thread safety Since ArrayList is not Synchronized, it's not thread safe means multiple threads can operate simultaneoulsy on ArrayList Since Vector is Synchronized, it's thread safe means only one thread can operate at time on Vector
3)Execution speed Since multiple threads can operate of ArrayList its faster Since only one thread operate at time on Vector its slow as compared to ArrayList
4)Capacity New capacity of Arraylist =( Initial capacity +(Initial capacity*3/2)+1) New capacity of Vector =2* initial capacity
5)Data retrival We can retrive data from ArrayList using iterator() only We can retrive data from Vector using iterator() as well as elements()
6)Duplicates Duplicates are allowed in ArrayList Duplicates are also allowed in Vector
7)Null insertion Null insertion is allowed in ArrayList Null insertion is also allowed in Vector
8)Insertion Order Insertion order is preserved in ArrayList Insertion order is preserved in Vector

You may also like...