标签:
public static Object goodCopyOf(Object a,int newLength){//该方法可以 用来扩展任意类型的数组 Class cl = a.getClass(); if (!cl.isArray()) return null; Class componentType = cl.getComponentType(); int length = java.lang.reflect.Array.getLength(a); Object newArray = java.lang.reflect.Array.newInstance(componentType,newLength); System.arraycopy(a,0,newArray,0,Math.min(length,newLength)); return newArray; }
源自:java核心技术1
标签:
原文地址:http://www.cnblogs.com/longforus/p/5408779.html