0 votes
in Education by (54.6k points)
List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5);

1 Answer

0 votes
by (54.6k points)

List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5);

IntSummaryStatistics stats = integers.stream().mapToInt((x) -> x).summaryStatistics();

System.out.println("Average of all numbers : " + stats.getAverage());

...