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:
Post a Comment