<Not to argue the point, but...> :-)
Robert Crawford observed:
> An array is not a data structure. An array assumes too much...
[much array-bashing snipped]
> Finally, "overhead" is a poor reason to choose an array.
> Considering he's using a connection to a database, I'd guess the
> latency between the servlet and the database to be very much
> larger than any extra work done in accessing a Vector.
Ummmm.... Valid points if the person uses something like:
private static final int MAX_SIZE = 50;
...but I was thinking of sizing the array based on the result set.
Once you have hit the database, there's no need to use a dynamically
sized data structure unless you're building a result set up from several
queries. I'd say that you're better off cutting down your (memory)
access time by using a fixed size structure. IIRC, a Vector is simply
an array wrapper anyway... If it's absolutely necessary to dynamically
size a data collection, you'd probably be better off creating (in this
case) a minimally functional wrapper that didn't implement
synchronization and other stuff that contributes to the generally poor
performance of Vectors.
I often use the Vector class when my code is evolving (just to avoid
having to think too hard :-), but I usually go back and replace the
Vectors with either an interface implementing collector (using arrays
underneath) or just a straight array.
It also keeps you from having to have a run-time type cast, since
Vectors only return Objects... And that's a nasty run-time exception,
too :-)
--
Within C++ is a smaller, cleaner language
struggling to get out.
It's called Java.
Thomas Moore
[EMAIL PROTECTED] Home Account
Software.Engineer [EMAIL PROTECTED]
phone://732.462.1880:268 NJ Patterns Group Home Page
employer://Celwave, RF http://members.home.net/twmoore/cjpg
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html