Online Java Compiler By
JavaTpoint.com
import java.util.Spliterator; import java.util.concurrent.ConcurrentLinkedQueue; class Information { String rollNo, name; int age; public Information(String rollNo, String name, int age) { this.rollNo = rollNo; this.name = name; this.age = age; } } public class ConcurrentLinkedQueueSpliteratorMethodExample3{ static int i=1; public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue(); Information val1 = new Information("15cs1029","Reema panda",21); Information val2 = new Information("15cs1012","Geetanjali Sharma",21); Information val3 = new Information("15cs1011","Himanshu Bhardwaj",21); queue.add(val1); queue.add(val2); queue.add(val3); Spliterator
str = queue.spliterator(); while(str.tryAdvance((n)->System.out.println(i++ +" Roll No = "+n.rollNo +"\n Name = "+n.name +"\n Age = "+n.age+"\n"))); } }
Output