aspose file tools*
The moose likes Beginning Java and the fly likes ArrayList vs. Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList vs. Vector" Watch "ArrayList vs. Vector" New topic
Author

ArrayList vs. Vector

sam leslie
Greenhorn

Joined: Jan 02, 2001
Posts: 1
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

Joined: Dec 19, 2000
Posts: 60
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

Joined: Sep 29, 2000
Posts: 8521
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.


"JavaRanch, where the deer and the Certified play" - David O'Meara
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
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


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList vs. Vector
 
Similar Threads
type casting
performance : arraylist vs vector
Multiple Thread allow to change single variable
Array List vs Vector
array