File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList vs. Vector

 
sam leslie
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any real difference between ArrayList and Vector? When should I use one over the other (if it matters at all).
Sam
 
Shakti Sharma
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ArrayList is class from collection framework , recent arrivals on the scene. The package java.util has always contained some other collection. Some are superseded by the new collection types like Vector superseded by ArrayList. Even so, they are not depricated because they are in wide use in existing code and will continue to be used until programmers shift over to new types.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ArrayList will never supercede Vector because Vector is synchronized and ArrayList is not. Therefore if you have an situation with multiple threads / users hitting on the same list then you either need to use Vector or wrap ArrayList in something that IS synchronized.
 
John Wetherbie
Rancher
Posts: 1449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want a synchronized ArrayList you can pass it to the Collections.synchronizedList() function and get back a synchronized version of the list you passed in.
John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic