1. 直接定义法:
int[][][] array = new int[rows][depth][width];
其中`rows`、`depth`和`width`分别代表数组的行数、深度(层数)和宽度(列数)。
2. 使用二维数组转三维数组:
public final static int[][] a0 = {
{0, 1, 2},
{3, 4, 5},
{4, 6, 7}
};
public final static int[][] a1 = {
{0, 4, 6},
{6, 8, 8},
{8, 8, 6}
};
public final static int[][][] array = {a0, a1};
3. 使用嵌套循环输入元素:
int[][][] array = new int[rows][depth][width];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < depth; j++) {
for (int k = 0; k < width; k++) {
array[i][j][k] = inputValue;
}
}
}
其中`inputValue`是你想要输入数组的值。
float[][][] array = new float[rows][depth][width];
请根据你的具体需求选择合适的方法来创建三维数组。