在Java中,为二维数组赋值有多种方法,以下是几种常见的方式:
直接赋值
int[][] array = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};
使用循环赋值
int[][] array = new int;for (int i = 0; i < array.length; i++) {for (int j = 0; j < array[i].length; j++) {array[i][j] = i + j;}}
使用`Arrays.fill()`方法
int[][] array = new int;int value = 1;for (int i = 0; i < array.length; i++) {Arrays.fill(array[i], value++);}

使用`System.arraycopy()`方法
int[][] source = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};int[][] destination = new int;System.arraycopy(source, 0, destination, 0, source.length);
使用Java 8的Stream API
int[][] array = new int;IntStream.range(0, array.length).forEach(i -> {IntStream.range(0, array[i].length).forEach(j -> array[i][j] = i * j);});
以上方法都可以用来初始化并赋值二维数组。选择哪一种方法取决于你的具体需求和编程风格
