Vector vs ArrayList
1 posts in topic
Flat View  Flat View

Posted By:   elango_maragtham
Posted On:   Tuesday, May 29, 2001 06:05 PM

Hi ..
I want to know the difference between Vector and ArrayList which is best to Use

Re: Vector vs ArrayList

Posted By:   AlessandroA_Garbagnati  
Posted On:   Wednesday, May 30, 2001 11:02 AM


I thought that John was going to answer this... :-)

Vector and ArrayList are very similar. Both of them represent a 'growable array', where you access to the elements in it through an index.

ArrayList it's part of the Java Collection Framework, and has been added with version 1.2, while Vector it's an object that is present since the first version of the JDK. Vector, anyway, has been retrofitted to implement the List interface.

The main difference is that Vector it's a synchronized object, while ArrayList it's not.

While the iterator that are returned by both classes are fail-fast (they cleanly thrown a ConcurrentModificationException when the orignal object has been modified), the Enumeration returned by Vector are not.

Unless you have strong reason to use a Vector, the suggestion is to use the ArrayList.
About | Sitemap | Contact