wood burning stoves 2.0*
The moose likes Java in General and the fly likes Array List vs Vector 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 » Java in General
Bookmark "Array List vs Vector" Watch "Array List vs Vector" New topic
Author

Array List vs Vector

Muhammad Aasim
Greenhorn

Joined: Oct 16, 2009
Posts: 9
What is difference between ArrayList and Vector? In which situation we use arrayList and Vector?

Answer:-ArrayList is like a resizeable array. ArrayList actually comes as a replacement the old "Vector" Collection. As we add or remove elements into or from it, it grow or shrinks over time?

Any thing else may please be tell?


EveRy THinG is pOssiBle bUt LovE caN NaveR FOr Me...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41049
    
  43
One difference is that the methods in Vector are all synchronized, whereas the methods in ArrayList are not. That's important in multi-threaded environments.


Ping & DNS - my free Android networking tools app
Fredrik Larsback
Greenhorn

Joined: Dec 21, 2009
Posts: 9
Vector is synchronized, ArrayList isn't.
Kaustav Ganguly
Greenhorn

Joined: Dec 14, 2009
Posts: 28
First thing is Vector also implements a resizable array like ArrayList, so both are resizable data structures. Vector class is there in Java since the begining and ArrayList was intoduced as part of the Collection framework. Vector class is also retrofitted into the java collection framework to implement the List interface in Java 2 v1.2 . And finally Vector is synchronized and ArrayList is not.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Array List vs Vector
 
Similar Threads
type casting
ArrayList & Vector
Technical Interview Questions
ArrayList & Vector
ArrayList / Vector