Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-24-2008, 04:52 PM   PM User | #1
adi501
New Coder

 
Join Date: Jul 2008
Location: Falls Chuch, VA
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
adi501 is an unknown quantity at this point
Help for accessing elements in a vector

Hello .

This is a simple question i guess. But i am stuck with it. I dont know where i am making a mistake.

I have a vector and i want to access the elements of the vector.

Ex:

Vectoe vRoles = new Vector();
// the following are the values in my vector
vRoles[0] = w; //
vRoles[1] = z;
vRoles[2] = y;
vRoles[3] = x;

i want to access the elements in order [w,x,y,z]. How can i do that ?
Please can anybody help me out with this.

Thanks in Advance.
adi501 is offline   Reply With Quote
Old 10-24-2008, 05:31 PM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
Assuming the vector stores strings

Code:
for ( String s : vRoles ) {
  System.out.println(s);
}
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:52 PM.


Advertisement
Log in to turn off these ads.