[英]How to read from an array which is inside a vector?
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处访问数组,以及如何在点i处访问向量,但是我不知道如何访问向量内的数组。 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) (因此数组的访问点i在向量的第一点)
No .
没有.
(period): (期):
vector.get(0)[i];
Note: Use ArrayList
or LinkedList
instead of Vector
(see this question/answer for details). 注意:使用ArrayList
或LinkedList
代替Vector
(有关详细信息,请参见此问题/答案 )。
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!
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.