Here you can find the source of copyOf(String[] data, int newLength)
public static String[] copyOf(String[] data, int newLength)
//package com.java2s; public class Main { public static String[] copyOf(String[] data, int newLength) { String[] tmp = new String[newLength]; System.arraycopy(data, 0, tmp, 0, Math.min(data.length, newLength)); return tmp; }// ww w .j av a 2 s. com }