wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is difference between ArrayList and 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is difference between ArrayList and Vector " Watch "what is difference between ArrayList and Vector " New topic
Author

what is difference between ArrayList and Vector

Prashant Neginahal
Ranch Hand

Joined: Dec 04, 2002
Posts: 76
Hi All,
what is the difference between ArrayList and Vector in terms of performance and its storage.
Thanks.


--------------<br />Prashant<br />SCJP-91%
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
As far as storage is concerned, they are the same since both use a backing Object array.
As for performance, all methods of the Vector class are synchronized, those of the ArrayList class are not. The ArrayList implementation is therefore better in terms of execution speed since accessing threads need not get the monitor prior to accessing the collection. The Vector class should not be used anymore since it is possible to get a synchronized ArrayList (when needed) by invoking Collections.synchronizedList().


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Prashant Neginahal
Ranch Hand

Joined: Dec 04, 2002
Posts: 76
Thanks Valentin Crettaz !!
 
Consider Paul's rocket mass heater.
 
subject: what is difference between ArrayList and Vector
 
Similar Threads
vector and arraylist
Question in Collection?
Vector deprecated in 1.3?
What is the difference between Vector and ArrayList
What is difference between ArrayList and vector?