Java Array Clone cloneIntArray(int array[])

Here you can find the source of cloneIntArray(int array[])

Description

Clone an integer array.

License

Open Source License

Parameter

Parameter Description
array The array to be cloned

Return

The new array

Declaration

public static int[] cloneIntArray(int array[]) 

Method Source Code

//package com.java2s;
//   it under the terms of the GNU General Public License as published by

public class Main {
    /**/*from w w  w. ja  va  2 s .  c o m*/
     * Clone an integer array.
     * @param array The array to be cloned
     * @return The new array
     */
    public static int[] cloneIntArray(int array[]) {
        int i, n;
        int[] arrayNew;
        // Do nothing for null pointers
        if (array == null)
            return null;
        // Otherwise copy and return
        n = array.length;
        arrayNew = new int[n];
        for (i = 0; i < n; i++) {
            arrayNew[i] = array[i];
        }
        return arrayNew;
    }
}

Related

  1. cloneArray(String[] orArray, int from)
  2. cloneByteArray(byte[] b)
  3. cloneBytes(byte[] buffer)
  4. cloneCharArray(char[] chars)
  5. cloneDoubleMatrix(double[][] src)
  6. cloneLong(long[] array)
  7. cloneNonNullArray(double[] array)
  8. cloneSubarray(byte[] array, int offset, int len)
  9. cloneSubArray(byte[] data, int offset, int size)