Java's Collectors class provides three summarizing factory methods (for int, long, and double) that gather statistics on a Stream in a single pass. Each returns a summary statistics object computing count, sum, mean, max, and average. These objects implement Consumer, computing stats in the accept method, making it easy to extend with custom statistics while supporting parallel streams.
•1m watch time
Sort: