LongStream summaryStatistics() example

Description

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;
/*from  w ww .ja  v a2s . 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.





















Home »
  Java Streams »
    Reference »




Collectors
DoubleStream
DoubleStream.Builder
IntStream
IntStream.Builder
LongStream
LongStream.Builder
Stream
Stream.Builder