This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vectors" Watch "Vectors" New topic


Salue Lek

Joined: Jul 13, 2001
Posts: 4
Can somebody point me to where I can learn more about vectors and how to go about filling them?
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9058
Moved to Java in General - no Vectors in these assignments

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
Well, there's the Java's API for java.util.Vector.
To fill a vector, you'll want to use java.util.Vector's add() method. To retrieve the nth element of a vector, you'll want to use the elementAt() method, which returns a java.lang.Object, so if you use elementAt(), you'll probably have to cast to what you need.
Here's a program I created for another JavaRancher some time back; it shows how to fill and retrieve elements from a vector:

This example may be overkill for your question, but it shows the use of a vector in action.
Good luck,
It is sorta covered in the JavaRanch Style Guide.
subject: Vectors
It's not a secret anymore!