执行阵列克隆的泛型方法
/* * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. * * Copyright (c) 2014, Gluu */ //package com.nowjava; /** * 时 代 J a v a - nowjava.com 提 供 **/ import java.lang.reflect.Array; public class Main { @SuppressWarnings("unchecked") public static <T> T[] arrayClone(T[] array) { if (array == null) { return array; } if (array.length == 0) { return (T[]) Array.newInstance(array.getClass() .getComponentType(), 0); } //from n o w j a v a . c o m T[] clonedArray = (T[]) Array.newInstance(array[0