Online Java Compiler By
JavaTpoint.com
import java.util.LinkedList; import java.util.List; import java.util.Spliterator; class Student{ String name; String school; String course; Student(String name, String school, String course){ this.name=name; this.school=school; this.course=course; } public String toString() { return " Name : "+this.name+" School : "+this.school+" Course : "+this.course; } } public class JavaListSpliteratorExample2 { public static void main(String[] args) { List
list = new LinkedList<>(); Student s1= new Student("Reema","Gita Convent School","Java"); Student s2= new Student("Geetu","Gita Convent School","Android"); Student s3= new Student("Saloni","Eicher Public School","Java"); list.add(s1); list.add(s2); list.add(s3); //spliterator split and then iterate the split parts in parallel Spliterator
str = list.spliterator(); // if the specified element exists then the tryAdvance() will perform the given action while(str.tryAdvance((n)->System.out.println(n))); } }
Output