Java Utililty Methods Array Deep Copy

List of utility methods to do Array Deep Copy

Description

The list of methods to do Array Deep Copy are organized into topic(s).

Method

int[][]deep_copy(int M[][])
Deep Copy - Make a deep copy of M[][].
int[][] C = new int[M.length][];
for (int i = 0; i < C.length; i++) {
    C[i] = Arrays.copyOf(M[i], M[i].length);
return C;
double[][]deepArrayCopy(double[][] original)
deep Array Copy
double[][] copy = original.clone();
for (int i = 0; i < copy.length; i++) {
    copy[i] = copy[i].clone();
return copy;
double[][]deepArrayCopy(double[][] original)
deep Array Copy
double[][] copy = new double[original.length][original[0].length];
for (int i = 0; i < copy.length; i++) {
    copy[i] = Arrays.copyOf(original[i], original[i].length);
return copy;
double[][]deepArrayCopy(double[][] original)
deep Array Copy
double[][] copy = new double[original.length][original[0].length];
for (int i = 0; i < copy.length; i++) {
    copy[i] = Arrays.copyOf(original[i], original[i].length);
return copy;
double[][]deepClone(double[][] ary)
deep Clone
double[][] res = ary.clone();
for (int i = 0; i < res.length; ++i)
    res[i] = ary[i].clone();
return res;
int[][]deepClone(int[][] source)
deep Clone
int[][] result = new int[source.length][];
for (int i = 0; i < source.length; i++)
    result[i] = source[i].clone();
return result;
byte[]deepCopy(byte[] org)
deep Copy
if (org == null)
    return null;
byte[] result = new byte[org.length];
System.arraycopy(org, 0, result, 0, org.length);
return result;
double[][]deepCopy(double[][] in)
deep Copy
double[][] out = new double[in.length][in[0].length];
for (int i = 0; i < in.length; i++)
    for (int j = 0; j < in[0].length; j++) {
        out[i][j] = in[i][j];
return out;
StringdeepCopy(final String s)
Does an deep copy of the input string and returns so input != (return value)
return new String(s);
int[]deepCopy(int[] array)
deep Copy
int[] copy = new int[array.length];
for (int i = 0; i < array.length; i++) {
    copy[i] = array[i];
return copy;