Java Streams - LongStream summaryStatistics() example








LongStream summaryStatistics() returns a LongSummaryStatistics describing various summary data about the elements of this stream.

Syntax

summaryStatistics has the following syntax.

LongSummaryStatistics summaryStatistics()

Example

The following example shows how to use summaryStatistics.

import java.util.LongSummaryStatistics;
import java.util.stream.LongStream;
/*w w w .ja v  a2  s.c o  m*/
public class Main {
  public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, 3L);
    
    LongSummaryStatistics l = b.summaryStatistics();
    
    System.out.println(l);
  }
}

The code above generates the following result.