DoubleStream skip(long n) 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.
Note : DoubleStream skip() is a stateful intermediate operation i.e, it may incorporate state from previously seen elements when processing new elements. Stateful intermediate operations may need to process the entire input before producing a result. For example, one cannot produce any results from sorting a stream until one has seen all elements of the stream.
Syntax :
DoubleStream skip(long n)
Parameter :
- DoubleStream : A sequence of primitive double-valued elements. This is the double primitive specialization of Stream.
- n : The number of leading elements to skip.
Return Value : The function returns the new stream after discarding first n elements.
Exception : The function throws IllegalArgumentException if n is negative.
Example 1 :
// Java code for DoubleStream skip() function import java.util.*; import java.util.stream.DoubleStream; class GFG { // Driver code public static void main(String[] args) { // Creating a DoubleStream DoubleStream stream = DoubleStream.of(5.5, 2.6, 4.6, 7.0, 13.2, 15.4); // Using skip() to skip first 3 values in DoubleStream // and displaying the rest of elements stream.skip(3).forEach(System.out::println); } } |
7.0 13.2 15.4
Example 2 :
// Java code for DoubleStream skip() function import java.util.*; import java.util.stream.DoubleStream; class GFG { // Driver code public static void main(String[] args) { // Creating a DoubleStream DoubleStream stream = DoubleStream.of(5.5, 2.6, 4.6, 7.0, 13.2, 15.4); // Using parallel skip() to skip first 3 values in range // and displaying the rest of elements stream.parallel().skip(3).forEach(System.out::println); } } |
13.2 7.0 15.4
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- DoubleStream.Builder build() in Java
- DoubleStream generate() method in Java
- DoubleStream forEach() method in Java
- DoubleStream forEachOrdered() method in Java
- DoubleStream sorted() in Java
- DoubleStream flatMap(DoubleFunction mapper) in Java
- DoubleStream summaryStatistics() in Java
- DoubleStream noneMatch() in Java with examples
- DoubleStream sum() in Java
- DoubleStream distinct() in Java with examples
- DoubleStream count() in Java with examples
- DoubleStream min() in Java with examples
- DoubleStream max() in Java with examples
- DoubleStream average() in Java with Examples
- DoubleStream filter() in Java with examples
- DoubleStream empty() in Java with examples
- DoubleStream iterator() in Java
- DoubleStream map(DoubleUnaryOperator mapper) in Java
- DoubleStream of() in Java
- DoubleStream parallel() in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

