This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Vector vs ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Vector vs ArrayList " Watch "Vector vs ArrayList " New topic
Author

Vector vs ArrayList

Nicky narayan
Greenhorn

Joined: Jul 01, 2009
Posts: 27

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: 449

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: 18541
    
    8

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: 27
Thank you so much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector vs ArrayList
 
Similar Threads
What is difference between ArrayList and vector?
Differentiate ArrayList and Vector
Question in Collection?
What is the difference between Vector and ArrayList
vector in vector