Example usage for java.util.stream LongStream limit

List of usage examples for java.util.stream LongStream limit

Introduction

In this page you can find the example usage for java.util.stream LongStream limit.

Prototype

LongStream limit(long maxSize);

Source Link

Document

Returns a stream consisting of the elements of this stream, truncated to be no longer than maxSize in length.

Usage

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, Long.MAX_VALUE, Long.MIN_VALUE);

    b.limit(2).forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.generate(() -> {
        return 2L;
    });/*from  w  ww . j  a  v a 2  s . c o  m*/

    b.limit(10).forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.iterate(1, (n) -> {
        return n + 1;
    });//ww w  . java2 s  .  co  m

    b.limit(10).forEach(System.out::println);
}