Java 8 Streams Java Java API
java.util.stream.DoubleStream
long count()
This terminal operation returns the count of elements in this stream. This is a special case of a reduction and is equivalent to:
mapToLong(e > 1L).sum()
package com.logicbig.example.doublestream;import java.util.stream.DoubleStream;public class CountExample { public static void main(String... args) { DoubleStream ds = DoubleStream.of(1.2, -1.3, 1.4, -1.5, 1.6, -1.7); long count = ds.count(); System.out.println(count); }}
6