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

Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

or learn thru JavaScript Online Training from India. Appreciating the persistence you put into your blog and detailed information you provide. Kindly keep blogging.

Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More