Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.Spliterator; import java.util.concurrent.ConcurrentLinkedQueue; public class JavaCollectionSpliteratorExample2 { static int i = 1; public static void main(String[] args) { Collection
collection = new ConcurrentLinkedQueue(); Information val1 = new Information("15", "Reema panda", 21); Information val2 = new Information("16", "Geetanjali Sharma", 21); Information val3 = new Information("17", "Ajeet Kumar Maurya XI", 36); collection.add(val1); collection.add(val2); collection.add(val3); Spliterator
str = collection.spliterator(); while (str.tryAdvance((n) ->System.out.println(i++ + " ID No = " + n.idNo+ "\n Name = " + n.name + "\n Age = " + n.age+ "\n"))) ; }; } class Information { String idNo, name; int age; public Information(String idNo, String name, int age) { this.idNo= idNo; this.name = name; this.age= age; } }
Output