1

I know how to access an array at point i, and how to access a vector at point i, but I can't figure out how to access an array which is inside a vector. I'm basically looking for code which does this:

  Vector.get(0).[i];

(So access point i of the array which is in the first point of the vector)

user650309
  • 2,639
  • 7
  • 28
  • 47

1 Answers1

7

No . (period):

vector.get(0)[i];

Note: Use ArrayList or LinkedList instead of Vector (see this question/answer for details).


Example:

public static void main(String... args) {
    Vector<String[]> vector = new Vector<String[]>();
    vector.add(new String[] {"Hello", "World!"});

    System.out.println(vector.get(0)[1]); // prints World!
}
Community
  • 1
  • 1
dacwe
  • 43,066
  • 12
  • 116
  • 140