Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Location
    Falls Chuch, VA
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post

    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.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •