ArrayList clone() method in Java with Examples Last Updated : 18 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The Java.util.ArrayList.clone() method is used to create a shallow copy of the mentioned array list. It just creates a copy of the list. Syntax: ArrayList.clone() Parameters: This method does not take any parameters. Return Value: This function returns a copy of the instance of Linked list. Below program illustrate the Java.util.ArrayList.clone() method: Example 1: Java // Java code to illustrate clone() method import java.io.*; import java.util.ArrayList; public class ArrayListDemo { public static void main(String args[]) { // Creating an empty ArrayList ArrayList<String> list = new ArrayList<String>(); // Use add() method // to add elements in the list list.add("Geeks"); list.add("for"); list.add("Geeks"); list.add("10"); list.add("20"); // Displaying the list System.out.println("First ArrayList: " + list); // Creating another linked list and copying ArrayList sec_list = new ArrayList(); sec_list = (ArrayList)list.clone(); // Displaying the other linked list System.out.println("Second ArrayList is: " + sec_list); } } Output: First ArrayList: [Geeks, for, Geeks, 10, 20] Second ArrayList is: [Geeks, for, Geeks, 10, 20] Example 2: Java // Java code to illustrate clone() method import java.io.*; import java.util.ArrayList; public class ArrayListDemo { public static void main(String args[]) { // Creating an empty ArrayList ArrayList<Integer> list = new ArrayList<Integer>(); // Use add() method // to add elements in the list list.add(10); list.add(20); list.add(30); list.add(40); list.add(50); // Displaying the list System.out.println("First ArrayList: " + list); // Creating another linked list and copying ArrayList sec_list = new ArrayList(); sec_list = (ArrayList)list.clone(); // Displaying the other linked list System.out.println("Second ArrayList is: " + sec_list); } } Output: First ArrayList: [10, 20, 30, 40, 50] Second ArrayList is: [10, 20, 30, 40, 50] Comment More infoAdvertise with us Next Article BitSet clone() Method in Java with Examples _Gaurav_Tiwari Follow Improve Article Tags : Java Practice Tags : Java Similar Reads BitSet clone() Method in Java with Examples The clone() Method Java.util.BitSet class is used to create a copy of an existing BitSet. The new BitSet is exactly equal to the existing one and is a mere copy of the previous BitSet. Syntax: Bit_Set.clone() Parameters: The method does not take any parameters. Return Value: The method just returns 2 min read Calendar clone() Method in Java with Examples The clear() method in Calendar class is used to clone a calendar object. It basically creates a shallow copy of this object. Syntax: public Object clone() Parameters: The method does not take any parameters. Return Value: The method does not return any value. Below programs illustrate the working of 2 min read CharacterIterator clone() method in Java with Examples The clone() method of java.text.CharacterIterator interface in Java is used to clone this CharacterIterator. It means that this method will create another instance of CharacterIterator with all the properties the same as this CharacterIterator and return it. Syntax: public Object clone() Parameter: 1 min read Date clone() method in Java with Examples The clone() method of Date class in Java returns the duplicate of the passed Date object. This duplicate is just a shallow copy of the given Date object.Syntax: public Object clone() Parameters: The method does not accept any parameters.Return Value: The method returns a clone of the object.Below pr 2 min read Stack clone() method in Java with Example The clone() method of Stack class is used to return a shallow copy of this Stack. It just creates a copy of the Stack. The copy will have a reference to a clone of the internal data array but not a reference to the original internal data array. Syntax: Stack.clone()Parameters: The method does not ta 2 min read Locale clone() Method in Java with Examples The clone() Method of Locale class in Java is used to simply create a clone or copy of an existing locale. The method copies the content of one locale to another. Syntax: Sec_Locale = First_Locale.clone() Parameters: This method does not take any parameters. Return Value: This method returns a clone 2 min read Like