Skip to content

Instantly share code, notes, and snippets.

@mcandre
Created January 19, 2015 17:25
Show Gist options
  • Save mcandre/368559f2f446a6989343 to your computer and use it in GitHub Desktop.
Save mcandre/368559f2f446a6989343 to your computer and use it in GitHub Desktop.
Java 8 Lambda test
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Stream;
import java.util.stream.Collectors;
public class LambdaTest {
public static void main(String[] args) {
ArrayList<Integer> xsList = new ArrayList<Integer>();
for (Integer i = 0; i < 10; i++) {
xsList.add(i);
}
Stream<Integer> xsParallelStream = xsList.stream().parallel();
List<Integer> ys = xsParallelStream.map( (Integer i) -> i * 2 ).collect(Collectors.toList());
for (Integer y: ys) {
System.out.println(y);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment