Difference between ArrayList and Vector

Q.What are key difference between ArrayList vs Vector in Java?
Ans.1) ArrayList is not thread safe where the Vector is i.e methods of vector are synchronized whereas ArrayList's methods are not.
2) ArrayList is fast as compared to Vector.
3) Vector and ArrayList both uses Array internally as data structure. They are dynamically resizable. Difference is in the way they are internally resized. By default, Vector doubles the size of its array when its size is increased. But, ArrayList increases by half of its size when its size is increased.
4) ArrayList has no default size while vector has a default size of 10.
5) In vector the data is retrieved using the elementAt() method while in ArrayList, it is done using the get() method. 

People who read this post also read :


Good differences, clear and concise. One more you can add is that vector was not member of collection framework prior to JDK 1.4 and later retrofitted into Collection API. see here for more differences between ArrayList and Vector in Java

Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More