大家好,又见面了,我是你们的朋友全栈君。
package org.fly.test;
public class ArrayTranfer {
public static void main(String[] args) {
int int2d[][] = { { 1, 2, 3, 9 }, { 4, 5, 6, 7, 8 } };
int[] int1d;
int len = 0;
for (int[] element : int2d) {
len += element.length;
}
int1d = new int[len];
int index = 0;
for (int[] array : int2d) {
for (int element : array) {
int1d[index++] = element;
}
}
for (int element : int1d) {
System.out.print(element + ",");
}
}
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/133277.html原文链接:https://javaforall.cn