Here you can find the source of copyOf(double[] array, int length)
public static double[] copyOf(double[] array, int length)
//package com.java2s; public class Main { public static double[] copyOf(double[] array, int length) { double[] result = new double[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i];/*from www.j a v a 2 s. c o m*/ } return result; } public static int[] copyOf(int[] array, int length) { int[] result = new int[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static float[] copyOf(float[] array, int length) { float[] result = new float[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static short[] copyOf(short[] array, int length) { short[] result = new short[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static long[] copyOf(long[] array, int length) { long[] result = new long[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static boolean[] copyOf(boolean[] array, int length) { boolean[] result = new boolean[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static byte[] copyOf(byte[] array, int length) { byte[] result = new byte[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static char[] copyOf(char[] array, int length) { char[] result = new char[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } public static Object[] copyOf(Object[] array, int length) { Object[] result = new Object[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; } return result; } }