Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at diehardtechy@gmail.com

Wednesday, September 17, 2014

Differences between ArrayList and Vector in Java

One of the most frequently asked question in java is what are the main differences between Vector and ArrayList ? Both Vector and ArrayList implements List interface, there are some differences in both classes.



Below are the few main differences between both the class.


Differences between ArrayList and Vector


S.No.
ArrayList
Vector
1.
All methods of ArrayList are non-synchronized.
Most of the methods of Vector class are synchronized.
2.
They are not thread safe.
They are thread safe.
3.
Multiple threads can operate at a same time.
Only one thread can operate at a time.
4.
Relatively performance is high as multiple thread are allowed to operate at a time.
Performance is relatively low as compare to ArrayList.
5.
ArrayList was introduced in java 1.2 versions; hence it is non – legacy class.
Vector was introduced in java 1.0, hence Vector class is known as legacy class.

No comments: