在Java中創建二維數組的方式有以下幾種:
int[][] array = new int[3][4];
int[][] array = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
int[][] array = new int[3][];
array[0] = new int[4];
array[1] = new int[4];
array[2] = new int[4];
int[][] array = new int[3][4];
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
array[i][j] = i * j;
}
}