Java 8 Streams Java Java API
Interface:
java.util.stream.LongStream
Method:
long count()
This method returns the count of elements in this stream. This is a special case of a reduction and is equivalent to: mapToLong(e > 1L).sum()
This is a terminal operation.
Examples
package com.logicbig.example.longstream;
import java.util.stream.LongStream;
public class CountExample {
public static void main(String... args) { LongStream stream = LongStream.range(1, 100); long count = stream.count(); System.out.println(count); } }
Output99
|