Here you can find the source of copyOf(Object[] array, int newLength)
public static Object[] copyOf(Object[] array, int newLength)
//package com.java2s; /*/* ww w. j av a2 s . c o m*/ * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. This * code is released under a tri EPL/GPL/LGPL license. You can use it, * redistribute it and/or modify it under the terms of the: * * Eclipse Public License version 1.0 * GNU General Public License version 2 * GNU Lesser General Public License version 2.1 */ public class Main { public static Object[] copyOf(Object[] array, int newLength) { final Object[] copy = new Object[newLength]; System.arraycopy(array, 0, copy, 0, Math.min(array.length, newLength)); return copy; } public static void arraycopy(Object[] src, int srcPos, Object[] dest, int destPos, int length) { System.arraycopy(src, srcPos, dest, destPos, length); } }