Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.Spliterator; import java.util.concurrent.ConcurrentLinkedQueue; public class JavaCollectionSpliteratorExample1 { static int i=1; public static void main(String[] args) { Collection
collection = new ConcurrentLinkedQueue(); for (int i=1;i<=10;i++) { collection.add(i); } System.out.print("Values : "); //spliterator split and iterate the split parts in parallel Spliterator
str = collection.spliterator(); // if element exists tryAdvance() will perform action while(str.tryAdvance((n)->System.out.print(n+" "))); } }
Output