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

double[][]clone(final double[][] array)
Clones a two dimensional array of floats.
if (array == null) {
    return null;
final double[][] result = new double[array.length][];
System.arraycopy(array, 0, result, 0, array.length);
for (int i = 0; i < array.length; i++) {
    final double[] child = array[i];
    final double[] copychild = new double[child.length];
...
int[]clone(final int[] original)
Returns a clone of the given mapping.
final int[] clone = new int[original.length];
System.arraycopy(original, 0, clone, 0, original.length);
return clone;
T[]clone(final T[] array)

Shallow clones an array returning a typecast result and handling null .

The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.

This method returns null for a null input array.

if (array == null) {
    return null;
return array.clone();
T[]clone(final T[] array)
Method to clone a array
if (array == null) {
    return null;
return array.clone();
T[]clone(final T[] array)
Shallow clones an array and handling null.
The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.
return array != null ? array.clone() : null;
float[]clone(float[] array)

Clones an array returning a typecast result and handling null.

if (array == null) {
    return null;
return (float[]) array.clone();
float[]clone(float[] f)
clone
float[] clone = new float[f.length];
for (int i = 0; i < clone.length; i++) {
    clone[i] = f[i];
return clone;
float[][]clone(float[][] array)
Clones a two dimensional array of floats.
if (array == null) {
    return null;
float[][] result = new float[array.length][];
System.arraycopy(array, 0, result, 0, array.length);
for (int i = 0; i < array.length; i++) {
    float[] child = array[i];
    float[] copychild = new float[child.length];
...
int[]clone(int[] a)
clone
if (a == null || a.length < 1) {
    return a;
int[] r = new int[a.length];
System.arraycopy(a, 0, r, 0, r.length);
return r;
int[]clone(int[] array)
clone
int[] ret = new int[array.length];
for (int c = 0; c < array.length; c++)
    ret[c] = array[c];
return ret;