Here you can find the source of copyOf(int[] old, int length)
public static int[] copyOf(int[] old, int length)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w . j a v a 2s .c om*/ * Identical to {@code Arrays.copyOf}, but GWT compatible. */ public static int[] copyOf(int[] old, int length) { int[] newArray = new int[length]; int minLength = Math.min(old.length, length); System.arraycopy(old, 0, newArray, 0, minLength); return newArray; } /** * Identical to {@code Arrays.copyOf}, but GWT compatible. */ public static double[] copyOf(double[] old, int length) { double[] newArray = new double[length]; int minLength = Math.min(old.length, length); System.arraycopy(old, 0, newArray, 0, minLength); return newArray; } /** * Identical to {@code Arrays.copyOf}, but GWT compatible. */ public static long[] copyOf(long[] old, int length) { long[] newArray = new long[length]; int minLength = Math.min(old.length, length); System.arraycopy(old, 0, newArray, 0, minLength); return newArray; } /** * Identical to {@code Arrays.copyOf}, but GWT compatible. */ public static String[] copyOf(String[] old, int length) { String[] newArray = new String[length]; int minLength = Math.min(old.length, length); System.arraycopy(old, 0, newArray, 0, minLength); return newArray; } public static int[][] copyOf(int[][] old) { int numRows = old.length; int numCols = old[0].length; int[][] copy = new int[numRows][numCols]; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numCols; j++) { copy[i][j] = old[i][j]; } } return copy; } }