forked from hellokaton/learn-java8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambdaTest10.java
More file actions
22 lines (19 loc) · 761 Bytes
/
Copy pathlambdaTest10.java
File metadata and controls
22 lines (19 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package lambda;
import java.util.Arrays;
import java.util.IntSummaryStatistics;
import java.util.List;
/**
* @author huanfuan
* @version 1.0
* @date 2019/8/8 0008 上午 11:12
*/
public class lambdaTest10 {
public static void main(String[] args) {
List<Integer> primes = Arrays.asList(2, 3, 5, 7, 11, 13, 17, 19, 23, 29);
IntSummaryStatistics stats = primes.stream().mapToInt((x) -> x).summaryStatistics();
System.out.println("Highest prime number in List : " + stats.getMax());
System.out.println("Lowest prime number in List : " + stats.getMin());
System.out.println("Sum of all prime numbers : " + stats.getSum());
System.out.println("Average of all prime numbers : " + stats.getAverage());
}
}