ConcurrentSkipListSet spliterator() method in Java Last Updated : 10 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.util.concurrent.ConcurrentSkipListSet.spliterator() method is an in-built function in Java which returns a weakly uniform Spliterator across the elements of this set. Syntax: ConcurrentSkipListSet.spliterator() Parameters: The function does not accept any parameter. Return Value: The function returns a Spliterator across the elements of this set. Below programs illustrate the ConcurrentSkipListSet.spliterator() method: Program 1: Java // Java Program Demonstrate Spliterator() // method of ConcurrentSkipListSet import java.util.Spliterator; import java.util.concurrent.ConcurrentSkipListSet; class ConcurrentSkipListSetSpliteratorExample1 { 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("best!!"); // spliterator split and iterate // the split parts in parallel Spliterator<String> str = set.spliterator(); // performs the action for each remaining element str.forEachRemaining( (n) -> { String lc = n.toUpperCase(); System.out.println(" Lower case = " + n); System.out.println(" Upper case = " + lc); System.out.println(); }); } } Output: Lower case = Gfg Upper case = GFG Lower case = best!! Upper case = BEST!! Lower case = is Upper case = IS Program 2: Java // Java Program Demonstrate Spliterator() // method of ConcurrentSkipListSet import java.util.Spliterator; import java.util.concurrent.ConcurrentSkipListSet; class ConcurrentSkipListSetSpliteratorExample2 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<Character> set = new ConcurrentSkipListSet<Character>(); // Adding elements to this set for (char ch = 'A'; ch <= 'Z'; ch++) { set.add(ch); } // Printing elements in the set System.out.print("The elements in the set are : "); // spliterator split and iterate // the split parts in parallel Spliterator<Character> str = set.spliterator(); // if element exists tryAdvance() will perform action while (str.tryAdvance((n) -> System.out.print(n + " "))) ; } } Output: The elements in the set are : A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#spliterator-- Comment More infoAdvertise with us Next Article ConcurrentSkipListSet pollLast() method in Java R rupesh_rao Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-ConcurrentSkipListSet +1 More Practice Tags : JavaJava-Collections Similar Reads 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 pollFirst() method in Java The pollFirst() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns retrieves and removes the first (lowest) element, or returns null if this set is empty. Syntax: public E pollFirst() Return Value: The function returns retrieves and removes the first ( 2 min read 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 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 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 ConcurrentLinkedQueue spliterator() method in Java The spliterator() method of ConcurrentLinkedQueue is used to get a Spliterator of the same elements as ConcurrentLinkedQueue. Created Spliterator is weakly consistent. It can be used with Streams in Java 8. Also it can traverse elements individually and in bulk too. Spliterator is better way to trav 2 min read Like