ConcurrentSkipListSet size() method in Java Last Updated : 17 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 elements in the queue. Below programs illustrate the ConcurrentSkipListSet.size() method: Program 1: Java // Java Program Demonstrate size() // method of ConcurrentSkipListSet import java.util.concurrent.ConcurrentSkipListSet; class ConcurrentSkipListSetSizeExample1 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<Integer> set = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set for (int i = 1; i <= 10; i++) set.add(i); // Printing the size of the set System.out.println("Number of elements in the set = " + set.size()); // Printing the elements System.out.println("set : " + set); } } Output: Number of elements in the set = 10 set : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Program 2: Java // Java Program Demonstrate size() // method of ConcurrentSkipListSet import java.util.concurrent.ConcurrentSkipListSet; class ConcurrentSkipListSetSizeExample2 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<String> set = new ConcurrentSkipListSet<String>(); // Adding elements to this set set.add("A"); set.add("B"); set.add("C"); set.add("D"); set.add("E"); // Printing the size of the set System.out.println("Number of elements in the set = " + set.size()); // Printing the elements System.out.println("set : " + set); } } Output: Number of elements in the set = 5 set : [A, B, C, D, E] Reference:https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#size-- Comment More infoAdvertise with us Next Article ConcurrentSkipListSet subSet() 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 subSet() method in Java subSet(E fromElement, E toElement) The subSet() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the 5 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 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 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 pollLast() method in Java The pollLast() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns retrieves and removes the last (highest) element, or returns null if this set is empty. Syntax: public E pollLast() Return Value: The function returns retrieves and removes the last (hig 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 Like