Simad | Tutoriel JAVA8 N°16: Collectors 3 SummarizingDouble,SummarizingInt,SummarizingLong @simad2288 | Uploaded August 2018 | Updated October 2024, 4 minutes ago.
The static method, Collectors.summarizingInt() returns a Collector which applies a mapping function to each input element of type T to convert it to primitive int, and returns summary statistics for the resulting integer values.
This tutorial explains how to use the predefined summarizing collectors returned by Collectors.summarizingInt(), Collectors.summarizingLong() and Collectors.summarizingDouble() methods with examples. It first explains the method definitions of these 3 methods, with insights into the structure of the Summary Statistics classes which encapsulate the calculated statistics returned by the collectors. It then shows how to use the summarizing collectors with a Java 8 code example, along with detailed explanation of the code.
Definition of summarizing collectors
The 3 summarizing collectors have almost identical signatures except for the type of data(int/ long/ double) they handle –
The static method, Collectors.summarizingInt() returns a Collector which applies a mapping function to each input element of type T to convert it to primitive int, and returns summary statistics for the resulting integer values.
This tutorial explains how to use the predefined summarizing collectors returned by Collectors.summarizingInt(), Collectors.summarizingLong() and Collectors.summarizingDouble() methods with examples. It first explains the method definitions of these 3 methods, with insights into the structure of the Summary Statistics classes which encapsulate the calculated statistics returned by the collectors. It then shows how to use the summarizing collectors with a Java 8 code example, along with detailed explanation of the code.
Definition of summarizing collectors
The 3 summarizing collectors have almost identical signatures except for the type of data(int/ long/ double) they handle –