Java 8 Streams Java Java API
Interface:
java.util.stream.LongStream
Method:
LongStream skip(long n)
This stateful intermediate operation returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream. If this stream contains fewer than n elements then an empty stream will be returned.
Examples
package com.logicbig.example.longstream;
import java.util.stream.LongStream;
public class SkipExample {
public static void main(String... args) { LongStream.of(4, 7, 9, 11, 13, 17) .skip(2) .forEach(System.out::println); } }
Output9 11 13 17
Parallel stream: package com.logicbig.example.longstream;
import java.util.stream.LongStream;
public class SkipExample2 {
public static void main(String... args) { LongStream.of(4, 7, 9, 11, 13, 17) .parallel() .skip(2) .forEach(System.out::println); } }
Output11 13 17 9
|
|