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.
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 ?
Joined: Apr 12, 2009
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 .
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.