我有2个数组,如a[3] = "1","2","3"
和b[3]="1","2","3"
。
将该2个数组合并为1个二维数组,如c[3][3]
c[][]
"1" "1"
"2" "2"
"3" "3"
我怎么能这样做?
答案 0 :(得分:2)
假设您的两个数组具有相同的长度,您可以简单地遍历它们,并为c[][]
构建双元素数组:
int commonLength = ... // This is the length shared by a and b
String[][] c = new String[commonLength][];
for (int i = 0 ; i != commonLength ; i++) {
c[i] = new String[] { a[i], b[i] };
}
答案 1 :(得分:0)
axis