| 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
|
|
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.
|
 |
 |
|
|
subject: Vector vs ArrayList
|
|
|