Add files via upload

This commit is contained in:
NKaushik89
2019-07-28 11:27:29 +05:30
committed by GitHub
parent a7d8ac59af
commit 822a28dd7c
6 changed files with 24 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
package spliterator;
import java.util.Arrays;
import java.util.List;
import java.util.stream.StreamSupport;
public class Main {
public static void main(String[] args){
List<Student> studentList = Arrays.asList(new Student("Alex", 23), new Student("Albert", 29), new Student("Brad", 33), new Student("Fred", 38), new Student("Max", 43));
StreamSupport.stream(new StudentSpliterator(studentList), true).forEach(e -> System.out.println("====>" + e.getAge()));
System.out.println(StreamSupport.stream(new StudentSpliterator(studentList), true).mapToInt(Student::getAge).sum());
StreamSupport.stream(new StudentSpliterator(studentList), false).forEach(e -> System.out.println("====>" + e.getAge()));
System.out.println(StreamSupport.stream(new StudentSpliterator(studentList), false).mapToInt(Student::getAge).sum());
}
}