File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes ArrayList vs. Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList vs. Vector" Watch "ArrayList vs. Vector" New topic
Author

ArrayList vs. Vector

Shenaz Assu
Ranch Hand

Joined: Sep 21, 2007
Posts: 32
Hey.. i know this question has been asked a 1000 times.. but still, wats the difference?? Other than Vector being Thread safe of course. I was asked this question in a interview and the interviewer was not happy at my answer about vector being thread safe is the only difference. He insisted that there are much more differences. Can anyone help me out??
[ October 03, 2007: Message edited by: Shenaz ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

Shenaz, welcome to JavaRanch.

First, please check your private messages. You can see them by clicking My Private Messages.

Vector is a legacy collection class, from the time of Java 1.0. In Java version 1.2, new collection classes were added that more or less replace the old classes. ArrayList is more or less the replacement of Vector.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
Take a look at this link for a technical comparison.
But I also think the most important difference is the fact that Vector is a legacy class (prior to java 1.2). When you only mention thread-save, you seem to imply that both can be valid choices, but almost always you should prefer ArrayList.
Shenaz Assu
Ranch Hand

Joined: Sep 21, 2007
Posts: 32
Thanks Bart. The link was very useful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList vs. Vector