Here you can find the source of matrixCopy(int[][] matrix)
public static int[][] matrixCopy(int[][] matrix)
//package com.java2s; //License from project: Apache License import java.util.Arrays; public class Main { public static int[][] matrixCopy(int[][] matrix) { if (matrix == null) { return null; }/*from ww w . j a v a2 s . co m*/ int[][] result = new int[matrix.length][]; for (int i = 0; i < matrix.length; ++i) { result[i] = Arrays.copyOf(matrix[i], matrix[i].length); } return result; } }