import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays.*;
class Ideone
{
public static void main
(String[] args
) {
List
<Integer
> integerList
= Arrays.
asList(0,
1,
2,
3,
42);
// sequential
long howManyOddNumbers = integerList.stream()
.filter(e -> (e%2) == 1).count();
System.
out.
println(howManyOddNumbers
); // Output: 2
// parallel
long howManyOddNumbersParallel = integerList.parallelStream()
.filter(e -> (e%2) == 1).count();
System.
out.
println(howManyOddNumbersParallel
); // Output: 2 }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuQXJyYXlzLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpCgl7CgkJTGlzdDxJbnRlZ2VyPiBpbnRlZ2VyTGlzdCA9IEFycmF5cy5hc0xpc3QoMCwgMSwgMiwgMywgNDIpOyAKCQkKCQkvLyBzZXF1ZW50aWFsIAoJCWxvbmcgaG93TWFueU9kZE51bWJlcnMgPSBpbnRlZ2VyTGlzdC5zdHJlYW0oKQoJCQkJCQkJCQkJCS5maWx0ZXIoZSAtPiAoZSUyKSA9PSAxKS5jb3VudCgpOyAKCQkKCQlTeXN0ZW0ub3V0LnByaW50bG4oaG93TWFueU9kZE51bWJlcnMpOyAvLyBPdXRwdXQ6IDIKCQkKCQkvLyBwYXJhbGxlbAoJCWxvbmcgaG93TWFueU9kZE51bWJlcnNQYXJhbGxlbCA9IGludGVnZXJMaXN0LnBhcmFsbGVsU3RyZWFtKCkKICAgICAgICAJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoZSAtPiAoZSUyKSA9PSAxKS5jb3VudCgpOwoKCQlTeXN0ZW0ub3V0LnByaW50bG4oaG93TWFueU9kZE51bWJlcnNQYXJhbGxlbCk7IC8vIE91dHB1dDogMgoJfQp9