The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Vector or Arrays......

Posted by Jody Brown on November 02, 2000 at 8:22 AM

mahantesh,

I assume that you mean when should you use an array of any type
of object, not just a String and when you should use a Vector.

Vector has a lot of useful methods to manipulate elements in the
array that arent dependent on the objects being held. Methods
such as indexOf, elementAt, removeElementAt are all useful
in manipulating vectors. Also, the Enumeration interface Vector
uses is very useful in traversing a vector.

Generally, I find that if I need to do a lot of work with the
data structure, such as adding, removing, changing elements,
I use a vector or hashtable. If the content is fairly static,
I use arrays.

Just my humble opinion though. There are many arguments for
and against using the different data structures in different
situations.

Regards,

Jody






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us