ConcurrentSkipListSet add() method in Java Last Updated : 17 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 a True boolean value. Below programs illustrate the ConcurrentSkipListSet.add() method: Program 1: Adding Integer in the set. Java // Java program to demonstrate add() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetAddExample1 { public static void main(String[] args) { // Creating a set object ConcurrentSkipListSet<Integer> Lset = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set for (int i = 10; i <= 50; i += 10) Lset.add(i); // Printing elements of the set System.out.println("The set contains: "); for (Integer i : Lset) System.out.print(i + " "); } } Output: The set contains: 10 20 30 40 50 Program 2: Adding String in the set. Java // Java program to demonstrate add() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetAddExample2 { public static void main(String[] args) { // Creating a set object ConcurrentSkipListSet<String> Lset = new ConcurrentSkipListSet<String>(); // Adding elements to this set Lset.add("alex"); Lset.add("bob"); Lset.add("chuck"); Lset.add("drake"); Lset.add("eric"); // Printing elements of the set System.out.println("The set contains: "); for (String i : Lset) System.out.print(i + " "); } } Output: The set contains: alex bob chuck drake eric Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#add(E) Comment More infoAdvertise with us Next Article ConcurrentSkipListSet clone() 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 clone() method in Java 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 sha 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 last() method in Java The last() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the last (highest) element currently in this set. Syntax: public E last() Return Value: The function returns returns the last (highest) element currently in this set. Exception: The function 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 higher() method in Java The higher(E e) method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the least element in this set strictly greater than the given element, or null if there is no such element. Syntax: public E higher(E e) Parameter: The function accepts a single paramet 2 min read Like