b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » XXX » Message 3066430 (Thread)

# Use the IF statement, luke...
(, Tue 20 Apr 2004, 1:29, archived)
# cant
have to use a vector

its part of an exam
(, Tue 20 Apr 2004, 1:30, archived)
# Urm ... read the API
They're just a container class.
You can add elements ...
You can remove elements ...
You can get the Nth element ...
Think of them as resizable arrays with silly (and non orthogonal) API.
Remember to get an enumeration from them if you need to process all the elements in a non-atomic manner (ie, to make callbacks or whatnot).
Actually the semantics of Vector suck lots and some of the Java 2 list classes/interfaces are a far better bet.

The only thing I'd really warn you against is using the seraching functionality (findElement() I think). It uses the equals() method to determine a match and it calls it on the array element, not the thing you passed in. This can lead to some unexpected results (always do searching manually, it's almost always more efficient).

EDIT: Nahh, it's indexOf() and contains() that suck like that.
(, Tue 20 Apr 2004, 2:08, archived)