ConcurrentSkipListSet clone() method in Java Last Updated : 17 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The clone() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns a shallow copy of this ConcurrentSkipListSet instance. Syntax: ConcurrentSkipListSet.clone() Parameters: The function does not accept any parameter. Return Value: The function returns a shallow copy of ConcurrentSkipListSet. Below programs illustrate the ConcurrentSkipListSet.clone() method: Program 1: Java // Java Program Demonstrate clone() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetCloneExample1 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<Integer> set = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set for (int i = 10; i <= 15; i++) set.add(i); // Printing elements of the set System.out.println("The set contains: " + set); // Cloning the ConcurrentSkipListSet ConcurrentSkipListSet<Integer> clone_set = set.clone(); // Adding elements to the clone set clone_set.add(16); // Printing elements of the clone set System.out.println("The clone set contains: " + clone_set); } } Output: The set contains: [10, 11, 12, 13, 14, 15] The clone set contains: [10, 11, 12, 13, 14, 15, 16] Program 2: Java // Java Program Demonstrate clone() // method of ConcurrentSkipListSet */ import java.util.concurrent.*; class ConcurrentSkipListSetCloneExample2 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<String> set = new ConcurrentSkipListSet<String>(); // Adding elements to this set set.add("Gfg"); set.add("is"); set.add("fun"); // Printing elements of the set System.out.println("The set contains: " + set); // Cloning the ConcurrentSkipListSet ConcurrentSkipListSet<String> clone_set = set.clone(); // Adding elements to the clone set clone_set.add("site"); // Printing elements of the clone set System.out.println("The clone set contains: " + clone_set); } } Output: The set contains: [Gfg, fun, is] The clone set contains: [Gfg, fun, is, site] Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#clone() Comment More infoAdvertise with us Next Article ConcurrentSkipListSet size() method in Java R rupesh_rao Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions Java-ConcurrentSkipListSet +2 More Practice Tags : JavaJava-CollectionsMisc Similar Reads ConcurrentSkipListSet clear() method in Java The java.util.concurrent.ConcurrentSkipListSet.clear() method is an in-built function in Java which removes all the elements from this set. Syntax: ConcurrentSkipListSet.clear() Parameters: The function does not accept any parameter. Return Value: The function does not return anything. Below program 2 min read ConcurrentSkipListSet add() method in Java The java.util.concurrent.ConcurrentSkipListSet.add() method is an in-built function in Java which is used to insert an element in this set. Syntax: ConcurrentSkipListSet.add(E e) Parameters: The function accepts a single parameter e i.e. the element to be inserted. Return Value: The function returns 2 min read ConcurrentSkipListSet size() method in Java The java.util.concurrent.ConcurrentSkipListSet.size() method is an in-built function in Java which gives the total count of the elements present in the set. Syntax: ConcurrentSkipListSet.size() Parameters: The function does not accept any parameter. Return Value: The function returns the number of e 2 min read ConcurrentSkipListSet first() method in Java The first() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the first (lowest) element currently in this set. Syntax: ConcurrentSkipListSet.first() Return Value: The function returns the first (lowest) element currently in this set. Exception: The f 1 min read ConcurrentSkipListSet remove() method in Java The java.util.concurrent.ConcurrentSkipListSet.remove() method is an in-built function in Java which is used to remove an element if it is present in this set. Syntax: ConcurrentSkipListSet.remove(Object o) Parameters: The function accepts a single parameter o i.e. the object to be removed. Return V 2 min read ConcurrentSkipListSet equals() method in Java The equals() method of java.util.concurrent.ConcurrentSkipListSet is an inbuilt function in Java which compares the specified object with this set for equality. It returns True if the specified object is also a set. The two sets will said to be equal if they satisfies all of the conditions stated be 3 min read Like