Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created March 29, 2017 19:08
Show Gist options
  • Save mauricioaniche/f6d7b5022c906ef9808259e2f1812f8f to your computer and use it in GitHub Desktop.
Save mauricioaniche/f6d7b5022c906ef9808259e2f1812f8f to your computer and use it in GitHub Desktop.
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