Add files via upload
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package data;
|
package spliterator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
19
java-8/spliterator/Main.java
Normal file
19
java-8/spliterator/Main.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package data;
|
package spliterator;
|
||||||
|
|
||||||
public class Student {
|
public class Student {
|
||||||
String name;
|
String name;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package data;
|
package spliterator;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package data;
|
package spliterator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package data;
|
package spliterator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
Reference in New Issue
Block a user