File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 9059
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,
I agree. Here's the link:
subject: Vectors
It's not a secret anymore!