hello!
I wonder how can one reach an element inside a vector, which it self is an element of another vector.
Ex:
Vector guide = new Vector();
Vector category1 = new Vector();
category1.addElement("item1");
guide.addElement(category1);
I want to reach item1 in category 1 directly from vector guide.
Tanks in advance
-
How to Access a vector inside another vector (2 messages)
- Posted by: masoud tehrani
- Posted on: March 13 2003 19:56 EST
Threaded Messages (2)
- try this by Raj Banyal on March 14 2003 00:28 EST
- How to Access a vector inside another vector by Lasse Koskela on March 14 2003 00:32 EST
-
try this[ Go to top ]
- Posted by: Raj Banyal
- Posted on: March 14 2003 00:28 EST
- in response to masoud tehrani
Vector guide = new Vector();
Vector category1 = new Vector();
category1.addElement("item1");
guide.addElement(category1);
System.out.println("---"+( (Vector) (guide.get(0)) ).get(0)); -
How to Access a vector inside another vector[ Go to top ]
- Posted by: Lasse Koskela
- Posted on: March 14 2003 00:32 EST
- in response to masoud tehrani
I think this should've been posted on a Java forum, not a Web Tier forum, but...
// your stuff
Vector guide = new Vector();
Vector category1 = new Vector();
category1.addElement("item1");
guide.addElement(category1);
// the "answer"
Vector innerVector = (Vector) guide.get(0); // get the first object in the vector
String item = (String) innerVector.get(0); // get the first object in the vector
System.out.println("item: " + item); // prints "item: item1"