Java Streams - IntStream skip(long n) example








IntStream skip(long n) returns a stream by discarding the first n elements of the stream.

Syntax

skip has the following syntax.

IntStream skip(long n)

Example

The following example shows how to use skip.

import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    IntStream i = IntStream.of(6,5,7,1, 2, 3, 4);
    i.skip(3)
     .forEach(System.out::println);
  }
}

The code above generates the following result.