1import java.util.ArrayList;
2public class ArrayListCloneMethodExample
3{
4 public static void main(String[] args)
5 {
6 ArrayList<String> al = new ArrayList<String>();
7 al.add("violet");
8 al.add("indigo");
9 al.add("blue");
10 al.add("green");
11 al.add("yellow");
12 System.out.println("ArrayList before using clone() method: " + al);
13 // create another ArrayList and copy
14 ArrayList<String> arrClone = new ArrayList<String>();
15 arrClone = (ArrayList)al.clone();
16 System.out.println("ArrayList after using clone() method: " + arrClone);
17 }
18}