Here you can find the source of copyOf(int[] arr)
public static int[] copyOf(int[] arr)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] copyOf(int[] arr) { int[] carr = new int[0]; if (arr != null) { carr = new int[arr.length]; System.arraycopy(arr, 0, carr, 0, arr.length); }//w w w . jav a2 s . c o m return carr; } public static int[] copyOf(int[] arr, int i) { int[] carr = new int[0]; if (arr != null) { if (i > arr.length) { i = arr.length; } carr = new int[i]; System.arraycopy(arr, 0, carr, 0, i); } return carr; } public static char[] copyOf(char[] arr) { char[] carr = new char[0]; if (arr != null) { carr = new char[arr.length]; System.arraycopy(arr, 0, carr, 0, arr.length); } return carr; } public static char[] copyOf(char[] arr, int i) { char[] carr = new char[0]; if (arr != null) { if (i > arr.length) { i = arr.length; } carr = new char[i]; System.arraycopy(arr, 0, carr, 0, i); } return carr; } public static byte[] copyOf(byte[] arr) { byte[] carr = new byte[0]; if (arr != null) { carr = new byte[arr.length]; System.arraycopy(arr, 0, carr, 0, arr.length); } return carr; } public static byte[] copyOf(byte[] arr, int i) { byte[] carr = new byte[0]; if (arr != null) { if (i > arr.length) { i = arr.length; } carr = new byte[i]; System.arraycopy(arr, 0, carr, 0, i); } return carr; } public static Object[] copyOf(Object[] arr) { Object[] carr = new Object[0]; if (arr != null) { carr = new Object[arr.length]; System.arraycopy(arr, 0, carr, 0, arr.length); } return carr; } public static Object[] copyOf(Object[] arr, int i) { Object[] carr = new Object[0]; if (arr != null) { if (i > arr.length) { i = arr.length; } carr = new Object[i]; System.arraycopy(arr, 0, carr, 0, i); } return carr; } public static String[] copyOf(String[] arr) { String[] carr = new String[0]; if (arr != null) { carr = new String[arr.length]; System.arraycopy(arr, 0, carr, 0, arr.length); } return carr; } public static String[] copyOf(String[] arr, int i) { String[] carr = new String[0]; if (arr != null) { if (i > arr.length) { i = arr.length; } carr = new String[i]; System.arraycopy(arr, 0, carr, 0, i); } return carr; } }