Created
March 29, 2017 19:08
-
-
Save mauricioaniche/f6d7b5022c906ef9808259e2f1812f8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
public class TesteMap { | |
public static void main(String[] args) { | |
List<Integer> nums = new ArrayList<Integer>(); | |
for(int i = 0; i < 50; i++) | |
nums.add(i); | |
// change 'stream()' to 'parallelStream()' | |
Stream<Integer> st = nums.stream().map(x -> { System.out.println("A " + x); return x;} ) | |
.filter(x -> { System.out.println("B " + x); return true; } ) | |
.map(x -> { System.out.println("C " + x); return x; } ); | |
System.out.println("lazy..."); | |
st.collect(Collectors.toList()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment