Java array clone
public class Main { public static void main(String args[]) { int[] array1 = { 1, 2, 3, 4, 5 }; String[] array2 = { "CSS", "HTML", "Java", "Javascript", "SQL", "C++", "C" }; System.out.println("Original size: " + array1.length); System.out.println("New size: " + cloneArray(array1).length); System.out.println("Original size: " + array2.length); System.out.println("New size: " + cloneArray(array2).length); }// www .java 2 s. c o m static int[] cloneArray(int[] original) { return (int[]) original.clone(); } static <T> T[] cloneArray(T original[]) { return (T[]) original.clone(); } }