IntSummaryStatistics is an object for collecting statistics such as count, min, max, sum, and average. Although not required, it is designed to work with streams. If you are working with longs use LongSummaryStatistics or doubles use DoubleSummaryStatistics.
Compute summary statistics on a stream
IntSummaryStatistics as a reduction target