Streams Summary Statistics in Java

First thing to remember summaryStatistics is only applicable for integer array/List not for strings.

This will provide summary information of integer list/array like min element,max element, sum ,count and avaerage.

int[] numbers = new int[]{2,1,3,5,6,7,8,9};
IntSummaryStatistics intSummaryStatistics = Arrays.stream(numbers)
.summaryStatistics();
System.out.println(intSummaryStatistics); Output : IntSummaryStatistics{count=8, sum=41, min=1, average=5.125000, max=9}

Tutorial :

https://youtu.be/In1jPT4-4oA

Loading


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *