PDA

View Full Version : Help for accessing elements in a vector


adi501
10-24-2008, 04:52 PM
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.

shyam
10-24-2008, 05:31 PM
Assuming the vector stores strings

for ( String s : vRoles ) {
System.out.println(s);
}