DEV Community

Streams em JAVA: Tudo que você precisa saber

Kauê Gatto on September 05, 2023

Map, Filter, Reduce Vamos começar com um exemplo? * Given a list of people * We need to compute the average of the age of those peopl...
Collapse
 
prsaya profile image
Prasad Saya

Max, Min, Avg?

You can also use IntSummaryStatistics:

IntSummaryStatistics stats = IntStream.of(2, 5, 9).summaryStatistics();
Enter fullscreen mode Exit fullscreen mode

java.util.IntSummaryStatistics is an object for collecting statistics such as count, min, max, sum, and average. For example stats.getAverage(), stats.getMax(), etc., or just print all statistics using the stats.toString().

Collapse
 
kauegatto profile image
Kauê Gatto

Totally forgot about IntSummaryStatistics, thanks for the complement!

Collapse
 
prsaya profile image
Prasad Saya

I know there are a lot of features in the Streams API. It may not be possible to list everything :)

Collapse
 
kauegatto profile image
Kauê Gatto

Peguei o texto do meu notion e post do medium, caso haja algum problema que não percebi, me avisem!