【Java】二维数组的简单扩容示例

public class Deep {
   public static void main(String[] args) {
        int[][] arr = new int[][]{{1,2,3},{4,5,6}};
        int[][] brr = Arrays.copyOf(arr,arr.length);
        System.out.println("arr 数组的值:" + Arrays.deepToString(arr));
        System.out.println("拷贝之后 brr 值:" + Arrays.deepToString(brr));
        int[][] crr = new int[brr.length][brr[0].length];
        arr[0][0] = 999;
        System.out.println("改变 arr 后的 brr 的值:" + Arrays.deepToString(crr));
   }
}

你可能感兴趣的:(课后作业)