Java中定義二維數組的方式如下:
int[][] arr = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int[][] arr = new int[3][3];
arr[0] = new int[]{1, 2, 3};
arr[1] = new int[]{4, 5, 6};
arr[2] = new int[]{7, 8, 9};
int[][] arr = new int[3][3];
arr[0][0] = 1;
arr[0][1] = 2;
arr[0][2] = 3;
arr[1][0] = 4;
arr[1][1] = 5;
arr[1][2] = 6;
arr[2][0] = 7;
arr[2][1] = 8;
arr[2][2] = 9;
請注意,以上三種方式都是有效的,您可以根據實際需求選擇適合的方式來定義二維數組。