二维数组的初始化赋值方法有两种:
- 使用静态初始化方式:
int[][] array = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
- 使用动态初始化方式:
int[][] array = new int[3][3]; array[0][0] = 1; array[0][1] = 2; array[0][2] = 3; array[1][0] = 4; array[1][1] = 5; array[1][2] = 6; array[2][0] = 7; array[2][1] = 8; array[2][2] = 9;