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

char[]arrayCopy(char[] chars)
array Copy
if (chars == null)
    return null;
char[] copy = new char[chars.length];
System.arraycopy(chars, 0, copy, 0, chars.length);
return copy;
double[][]arrayCopy(double[][] src)
Copies all rows and columns between two double arrays
double[][] dest = new double[src.length][];
for (int r = 0; r < src.length; r++) {
    dest[r] = new double[src[r].length];
    System.arraycopy(src[r], 0, dest[r], 0, src[r].length);
return dest;
voidarrayCopy(final byte[] src, final byte[] dest)
Copy array with zero offsets.
System.arraycopy(src, 0, dest, 0, src.length);
float[]arrayCopy(final float[] arrayToCopy)
Copy an array.
return Arrays.copyOf(arrayToCopy, arrayToCopy.length);
int[]arrayCopy(int[] array, int i0, int n, boolean isReverse)
array Copy
if (array == null)
    return null;
int oldLength = array.length;
if (n == -1)
    n = oldLength;
if (n == -2)
    n = oldLength / 2;
n = n - i0;
...
int[]arrayCopy(int[] array, int length)
Copy an array into a new array with the given length.
int[] result = new int[length];
length = Math.min(array.length, length);
System.arraycopy(array, 0, result, 0, length);
return result;
int[]arrayCopy(int[] x)
array Copy
int z = 0;
int[] l = new int[x.length + 1];
for (int i = 0; i < x.length; i++) {
    int y = x[i];
    if (y != 0) {
        l[z] = y;
        z++;
int[] n = new int[z];
System.arraycopy(l, 0, n, 0, z);
return n;
voidarrayCopy(int[][] source, int[][] destination)
array Copy
for (int a = 0; a < source.length; a++) {
    System.arraycopy(source[a], 0, destination[a], 0, source[a].length);
voidarraycopy(long src[], int srcOffset, long dest[], int destOffset, int limit)
arraycopy
if (src == dest) {
    if (srcOffset == destOffset) {
        return;
    if (destOffset > srcOffset && destOffset < srcOffset + limit) {
        limit--;
        srcOffset += limit;
        destOffset += limit;
...
voidarraycopy(long[] src, int srcPos, long[] dest, int destPos, int length)
arraycopy
for (int i = 0; i < length; i++) {
    dest[destPos + i] = src[srcPos + i];