Java examples for Collection Framework:Array Clone
Generic method to clone array
//package com.java2s; import java.lang.reflect.Array; public class Main { public static <T> T[] clone_array(T[] array, Class<T> cls) throws Exception { T[] copy = (T[]) Array.newInstance(cls, array.length); for (int i = 0; i < array.length; i++) { copy[i] = array[i];/*from w w w . j a v a2 s. com*/ } return copy; } }