将所有数组合并为单个数组。
/** 来 自 时 代 J a v a 公 众 号 - nowjava.com **/ //package com.nowjava; import java.lang.reflect.Array; public class Main { /** * Merged all arrays into a single array. */ @SuppressWarnings("unchecked") public static <T> T[] merge(final T[]... arrays) { // Compute total size Class<T> type = null; int size = 0; for (final T[] array : arrays) { size += array.length; if (type == null && array.length > 0) { type = (Class<T>) array[0].getClass(); } } // Copy all arrays/** 来自 N o w J a v a . c o m**/ final T[] merged = (T[]) Array.newInstance(type, size); int index = 0; for (