This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vectors

 
Salue Lek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody point me to where I can learn more about vectors and how to go about filling them?
thanks,
Salue
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General - no Vectors in these assignments
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Art
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic