ArrayList / Vector

Hello All,

I put the result from the database as a list of transfer objects ...is it better to use ArrayList or Vector to store them and use them in my action, jsp etc......I know using vector adds the synchronization overhead but someone advised that storing data in a vector is more advantageous...

Help is greatly appreciated...

Thanks,

maithri...

Message was edited by:

Maithri

[425 byte] By [Maithria] at [2007-11-27 1:23:01]
# 1
Vector is a legacy class. Use ArrayList unless other methods are expecting a Vector.
DrLaszloJamfa at 2007-7-12 0:11:03 > top of Java-index,Java Essentials,Java Programming...
# 2

Typically, Vector is only recommended when your code needs to run in an older jvm, say version 1.2. Otherwords, array list is almost always recommended.

Even when you need synchronization, the ArrayList can become synchronized, and since you have to do that explicitly, a maintainer knows that you are doing operations that require synchronization, as opposed to using Vector, where you get synchronization whether you want it or not, so that doesn't tell the maintainer much.

- Adam

guitar_man_Fa at 2007-7-12 0:11:03 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks a lot for your views...I'll go on with ArrayList ...Thank You ,Maithri
Maithria at 2007-7-12 0:11:03 > top of Java-index,Java Essentials,Java Programming...