Java Array Copy copyArray(double[] a)

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

Description

Returns a copy of the specified array.

License

LGPL

Declaration

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

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**//from w  w w  . j  a  v  a 2  s  .  c  om
     * Returns a copy of the specified array.
     */
    public static double[] copyArray(double[] a) {
        if (a != null) {
            return copyArray(a, a.length);
        } else {
            return null;
        }
    }

    /**
     * Returns a copy of the first <tt>length</tt> elements of the specified array.
     */
    public static double[] copyArray(double[] a, int length) {
        if (a == null) {
            return null;
        }
        double[] copy = new double[length];
        System.arraycopy(a, 0, copy, 0, length);
        return copy;
    }

    /**
     * Returns a copy of the specified array.
     */
    public static int[] copyArray(int[] a) {
        if (a == null) {
            return null;
        }
        int[] copy = new int[a.length];
        System.arraycopy(a, 0, copy, 0, a.length);
        return copy;
    }

    /**
     * Returns a copy of the specified 2-dimensional array.
     */
    public static double[][] copyArray(double[][] a) {
        double[][] copy = new double[a.length][];
        for (int i = 0; i < a.length; i++) {
            copy[i] = copyArray(a[i]);
        }
        return copy;
    }
}

Related

  1. copyAndFillOf(T[] original, int newLength, T padding)
  2. copyArray()
  3. copyArray(byte[] dest, int off, byte[] src)
  4. copyArray(byte[] original, int start, int length)
  5. copyArray(byte[] out, byte[] in, int idx)
  6. copyArray(double[] array)
  7. copyArray(double[] src, double[] dest, int len)
  8. copyArray(double[][] d)
  9. copyArray(int[] ar)