This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Threads and Synchronization and the fly likes Vector vs ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Vector vs ArrayList " Watch "Vector vs ArrayList " New topic
Author

Vector vs ArrayList

Nicky narayan
Greenhorn

Joined: Jul 01, 2009
Posts: 24

What is the main difference b/w ArrayList and Vector?

As of my knowledge- Vector is Synchronized and ArrayList is not Synchronized.

But, we can synchronize the AyyaList by using Collections.synchronizeList(ArrayList).

then what is the main difference in between these two ?

Nicky
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 341
Vector is a legacy class that is from Java 1.0 where as ArrayList introduce in Java 1.2 with the Collection Framework. The reason why Vector still exist because removing the class would result in break the client programmer’s code. You should not use Vector in new code. If you need a synchronized collection then you can use the method as you have already specified .


http://muhammadkhojaye.blogspot.com/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16479
    
    2

Like Muhammad says, just use ArrayList. Asking what is the "main difference" between two things is almost always pointless.

Not to mention that using a class just because it is "synchronized" is likely to lead you into problems when you assume that the word "synchronized" means more than it actually does. So yes, use ArrayList and also study more about synchronization.
Nicky narayan
Greenhorn

Joined: Jul 01, 2009
Posts: 24
Thank you so much.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Vector vs ArrayList
 
Similar Threads
Differentiate ArrayList and Vector
What is the difference between Vector and ArrayList
What is difference between ArrayList and vector?
Question in Collection?
vector in vector