在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);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 rows = 3;int columns = 3;int value = 1;int[][] array = IntStream.range(0, columns).mapToObj(j -> value++).toArray(int[][]::new);
