Java tutorial
//package com.java2s; import java.lang.reflect.Array; public class Main { /** * * @param src * @param dst * @return */ @SuppressWarnings("unchecked") public static <T> T[] instanceArray(T src[], T dst[]) { T ret[] = null; if (src != null) { if (dst == null || dst.length != src.length) { dst = (T[]) Array.newInstance(src.getClass().getComponentType(), src.length); } ret = dst; System.arraycopy(src, 0, ret, 0, src.length); } return ret; } }