Examples for java stream api
This commit is contained in:
22
java-8/stream-api/ExampleParallelStream.java
Normal file
22
java-8/stream-api/ExampleParallelStream.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExampleParallelStream {
|
||||
public static void main(String[] args) {
|
||||
List<Integer> intList = new ArrayList<>();
|
||||
|
||||
intList.add(1);
|
||||
intList.add(2);
|
||||
intList.add(3);
|
||||
intList.add(4);
|
||||
intList.add(5);
|
||||
|
||||
intList.parallelStream().
|
||||
filter(e -> {
|
||||
System.out.println("filter " + e);
|
||||
return true;
|
||||
}).
|
||||
forEach(e -> System.out.println("ForEach " + e));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user