Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector

 
nicky sajdok
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
my vector holds these values
[goods out, firstname, lastname]
[id, adress1]
[country, phone]
[goods in]
How can i get the first line out([goods out, firstname, lastname]).
and after i have used this line get the next line out([id, adress1]).
And so on?
thanks
nicky
 
Dominic Paquette
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the Vector class you can get an element using elementAt(int index) function. I assume the elements are String[].
Vector v = new Vector();
v.add(new String[]{"string1", "string 2"});
v.add(new String[]{"string3", "string 4"});

String[] strArray = (String[])v.elementAt(0);
Hope this helps
 
nicky sajdok
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
well when i try to run my code i get exception
java.lang.classCastException:
Why is this?
nicky
 
Dominic Paquette
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your probably casting the returned element to the wrong type.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic