Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the differences between Vector and ArrayList? Which is best to use?

0
Posted

What are the differences between Vector and ArrayList? Which is best to use?

0

Location: http://www.jguru.com/faq/view.jsp?EID=433158 Created: Jun 3, 2001 Author: Alessandro A. Garbagnati (http://www.jguru.com/guru/viewbio.jsp?EID=32727) Question originally posed by elango maragtham (http://www.jguru.com/guru/viewbio.jsp?EID=248437 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 t

Related Questions

Thanksgiving questions

*Sadly, we had to bring back ads too. Hopefully more targeted.