• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parsing elements of a Vector

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
elements of a vector:
[a1,a2,a3] // first element
[b1,b2,b3] // sec element and so on

how can i parse each individual element...like i want ot be able to read a1,a2...b3 individually ??
is it possible and if so how ??
thanks
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying the elements of the Vector are arrays? You will have to retrieve the elements individually, cast each one to an array, then access the array.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steven,
It would be helpful to indicate what the type each of the vector elements are and what type the individual elements are - but I'll try to help.
Assuming v is your Vector:

[ March 06, 2003: Message edited by: Lu Battist ]
 
Steven Jones
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Thanks to Greg & Lu.
i guess my question wasnt clear earlier.
i have:
Vector Vect1
Elements of Vect1 are again vectors.(say v1,v2 and so on)
v1 has string elements a1,a2,a3
v2 has string elements b1,b2,b3 etc.,
now i dont have references to the vectors v1,v2 etc.,
when i use Vect1.elementAt(1), i get [a1,a2,a3]
how can i read/get each of these string elements individually??
hope my ? is clear.
thanks
Steven
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So basically, you want a two dimensional "array" of Vectors. Assuming the outer vectors has the rows, you want something like...

Note that in most cases you probably want to use ArrayList (and the Collections package) instead of Vector.
--Mark
 
Steven Jones
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic