Java Array Clone clone2DArray(double[][] a)

Here you can find the source of clone2DArray(double[][] a)

Description

Clones a two-dimensional matrix.

License

Open Source License

Parameter

Parameter Description
a The matrix to copy.

Return

A clone of the matrix or null if parameter a is null.

Declaration

public static double[][] clone2DArray(double[][] a) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// ww w.  j  av a 2  s  .c  o m
     * Clones a two-dimensional matrix.
     * @param a The matrix to copy.
     * @return A clone of the matrix or null if parameter a is null.
     */
    public static double[][] clone2DArray(double[][] a) {

        if (a == null)
            return null;

        double[][] copy = new double[a.length][a.length == 0 ? 0 : a[0].length];
        for (int i = 0; i < a.length; i++) {
            System.arraycopy(a[i], 0, copy[i], 0, a[i].length);
        }

        return copy;

    }
}

Related

  1. clone(Object[] src, Object[] trg)
  2. clone(String[] array)
  3. clone(T[] array)
  4. clone(T[] array)
  5. clone(T[] array)
  6. clone2DArray(Double[][] array)
  7. clone2dArray(double[][] myArray)
  8. clone2DArray(final boolean[][] array)
  9. clone_multidim_array(float[][] arr)