Java Utililty Methods Array Clone

List of utility methods to do Array Clone

Description

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

Method

boolean[]clone(boolean[] array)

Clones an array returning a typecast result and handling null.

if (array == null) {
    return null;
return copyOf(array, array.length);
boolean[]clone(boolean[] array)
clone
boolean[] newArray = new boolean[array.length];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
boolean[]clone(boolean[] in)
clone
boolean[] ret = new boolean[in.length];
System.arraycopy(in, 0, ret, 0, in.length);
return ret;
byte[]clone(byte[] input)
Clone a byte array.
if (input == null) {
    return null;
byte[] ret = new byte[input.length];
System.arraycopy(input, 0, ret, 0, input.length);
return ret;
byte[]clone(byte[] orig)
Clone a byte array, maintaining awareness of null arrays
if (orig == null)
    return null;
return (byte[]) orig.clone();
byte[][]clone(byte[][] im)
clone
byte[][] clone = new byte[im.length][im[0].length];
copy(clone, im);
return clone;
double[]clone(double[] array)
Return a new copy of a double aray holding the same elements
if (array == null) {
    return null;
double[] clone = new double[array.length];
for (int i = 0; i < array.length; i++) {
    clone[0] = array[i];
return clone;
...
double[]clone(double[] p)
clone
double[] ret = new double[p.length];
System.arraycopy(p, 0, ret, 0, p.length);
return ret;
double[][]clone(double[][] source)
Returns a clone of the specified array.
if (source == null) {
    throw new IllegalArgumentException("Null 'source' argument.");
double[][] clone = new double[source.length][];
for (int i = 0; i < source.length; i++) {
    if (source[i] != null) {
        double[] row = new double[source[i].length];
        System.arraycopy(source[i], 0, row, 0, source[i].length);
...
byte[]clone(final byte[] array)
Clones an array of bytes.
return clone(array, 0, array.length);