Java Utililty Methods Array Copy

List of utility methods to do Array Copy

Description

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

Method

double[][]copyArray(double[][] d)
copy Array
int size = d.length;
double res[][] = new double[size][size];
for (int r = 0; r < size; r++)
    for (int c = 0; c < size; c++)
        res[r][c] = d[r][c];
return (res);
int[]copyArray(int[] ar)
copy Array
int[] r = new int[ar.length];
System.arraycopy(ar, 0, r, 0, ar.length);
return r;
voidcopyArray(int[] inArr, int[] outArr)
copy Array
for (int i = 0; i < inArr.length; i++) {
    outArr[i] = inArr[i];
int[][]copyArray(int[][] arr)
copy Array
int[][] result = new int[arr.length][];
for (int i = 0, c = result.length; i < c; i++) {
    result[i] = arr[i].clone();
return result;
int[][]copyArray(int[][] links, int rowNum, int columnNum)
copy Array
int[][] result = new int[rowNum][columnNum];
for (int i = 0; i < rowNum; ++i) {
    for (int j = 0; j < columnNum; ++j) {
        result[i][j] = links[i][j];
return result;
int[][]copyArray(int[][] src)
copy Array
int[][] ret = new int[src.length][src[0].length];
for (int i = 0; i < ret.length; i++) {
    System.arraycopy(src[i], 0, ret[i], 0, src[0].length);
return ret;
int[][][]copyArray(int[][][] data)
Copies the given array to a new one that it returns
return copyArray(data, 0, 0, data[0].length, data.length);
long[]copyArray(long[] array)
copy Array
if (array == null) {
    return new long[0];
if (array.length == 0) {
    return new long[0];
} else {
    long[] ret = new long[array.length];
    System.arraycopy(array, 0, ret, 0, array.length);
...
voidcopyArray(Object source, Object dest, int count)
Convenience wrapper for System.arraycopy().
System.arraycopy(source, 0, dest, 0, count);
Object[]copyArray(Object[] array)
copy Array
if (null == array)
    return null;
final Object[] copy = new Object[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
return copy;