LongStream skip(long n) example

Description

LongStream skip(long n) returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.

Syntax

skip has the following syntax.


LongStream skip(long n)

Example

The following example shows how to use skip.


import java.util.stream.LongStream;
//from   w  w  w  . ja va2 s  . c om
public class Main {
  public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, Long.MAX_VALUE, Long.MIN_VALUE);

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

The code above generates the following result.





















Home »
  Java Streams »
    Reference »




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