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 :
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
public static void main(String[] args)
{
DoubleStream stream =
DoubleStream.of( 5.5 , 2.6 , 4.6 , 7.0 , 13.2 , 15.4 );
stream.skip( 3 ).forEach(System.out::println);
}
}
|
Example 2 :
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
public static void main(String[] args)
{
DoubleStream stream =
DoubleStream.of( 5.5 , 2.6 , 4.6 , 7.0 , 13.2 , 15.4 );
stream.parallel().skip( 3 ).forEach(System.out::println);
}
}
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!