public class ArrayUtils { /** * 轉爲ArrayList * @param src 須要轉化的對象 * @param <T> * @return ArrayList */ public static <T> ArrayList<T> toArrayList(@NonNull List<T> src) { if (src instanceof ArrayList) { return (ArrayList<T>) src; } else { ArrayList<T> result = new ArrayList<>(src.size()); result.addAll(src); return result; } } }