clone two dimensinal Array - Android java.lang

Android examples for java.lang:array copy

Description

clone two dimensinal Array

Demo Code


public class Main{

    public static int[][] cloneArray(int[][] src) {
        int[][] dst = new int[src.length][];
        for (int i = 0; i < src.length; i++) {
            int[] aMatrix = src[i];
            int aLength = aMatrix.length;
            dst[i] = new int[aLength];
            System.arraycopy(aMatrix, 0, dst[i], 0, aLength);
        }/*from  w  w w. ja v  a2  s. com*/
        return dst;
    }

}

Related Tutorials