如题所述
是要合并么?
public class $ {public static void main(String[] args) {
int[] a = { 1, 2, 3, 4, 5 };
int[] b = { 6, 7, 8, 9, 10 };
int[] c = new int[a.length + b.length];
int index = 0;
for (int i : a) {
c[index++] = i;
}
for (int i : b) {
c[index++] = i;
}
for (int i : c) {
System.out.print(i + "->");
}
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2013-08-27
你没说清楚,不知你 要什么样的
public static void main(String args[]) {
int a[] = {1,2,3,4,5};
int b[] = {6,7,8,9,10};
int[][] c = {a,b};
for(int i = 0; i < c.length; i++){
for(int j = 0; j < b.length; j++){
System.out.print(c[i][j] + "\t");
}
System.out.println();
}
}
参考下
public static void main(String args[]) {
int a[] = {1,2,3,4,5};
int b[] = {6,7,8,9,10};
int[][] c = {a,b};
for(int i = 0; i < c.length; i++){
for(int j = 0; j < b.length; j++){
System.out.print(c[i][j] + "\t");
}
System.out.println();
}
}
参考下