Java Array Clone cloneArray(int[] array)

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

Description

Creates a copy of string array.

License

LGPL

Parameter

Parameter Description
array an int array

Return

a cloned int array

Declaration

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

Method Source Code

//package com.java2s;
/*/*from  w w  w  . jav  a 2  s  .  c o  m*/
 *   This software is distributed under the terms of the FSF 
 *   Gnu Lesser General Public License (see lgpl.txt). 
 *
 *   This program is distributed WITHOUT ANY WARRANTY. See the
 *   GNU General Public License for more details.
 */

public class Main {
    /**
     * Creates a copy of string array.
     * 
     * @param array an int array
     * @return a cloned int array
     */
    public static int[] cloneArray(int[] array) {
        if (array == null)
            return null;
        int[] a = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            a[i] = array[i];
        }
        return a;
    }

    /**
     * Creates a copy of string array.
     * 
     * @param array a String array
     * @return a cloned String array
     */
    public static String[] cloneArray(String[] array) {
        if (array == null)
            return null;
        String[] a = new String[array.length];
        for (int i = 0; i < array.length; i++) {
            a[i] = array[i];
        }
        return a;
    }
}

Related

  1. cloneArray(byte[] bytes)
  2. cloneArray(byte[] in)
  3. cloneArray(double[][] a)
  4. cloneArray(Double[][] src)
  5. cloneArray(final String[] inputArray)
  6. clonearray(int[] clonethis)
  7. cloneArray(int[] src)
  8. cloneArray(String[] orArray, int from)
  9. cloneByteArray(byte[] b)