Here you can find the source of cloneArray(int[] array)
Parameter | Description |
---|---|
array | an int array |
public static int[] cloneArray(int[] array)
//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; } }