Here you can find the source of castArray(Object[] array, T[] targetArray)
@SuppressWarnings("unchecked") public static <T> T[] castArray(Object[] array, T[] targetArray)
//package com.java2s; //License from project: Open Source License public class Main { @SuppressWarnings("unchecked") public static <T> T[] castArray(Object[] array, T[] targetArray) { for (int i = 0; i < array.length; i++) { targetArray[i] = (T) array[i]; }//w w w . j a v a 2 s .c o m return targetArray; } }