Stream skip(long n) example
Description
Stream 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.
Stream<T> skip(long n)
Example
The following example shows how to use skip
.
import java.util.Arrays;
import java.util.List;
/* w w w .ja v a 2s . c o m*/
public class Main {
public static void main(String[] args) {
List<String> stringList = Arrays.asList("1","1","2","3","4");
stringList.stream()
.skip(2)
.forEach(System.out::println);
}
}
The code above generates the following result.