DoubleStream skip() method in Java


The skip() method of the DoubleStream class in Java returns a stream consisting of the remaining elements of this stream after discarding the first numEle elements of the stream. The numEle is a parameter which you can set to skip any number of elements from the stream.

The syntax is as follows −

DoubleStream skip(long numEle)

Here, numEle is the number of elements to skip. The leading elements are skipped.

To use the DoubleStream class in Java, import the following package −

import java.util.stream.DoubleStream;

The following is an example to implement DoubleStream skip() method in Java −

Example

 Live Demo

import java.util.stream.DoubleStream;
public class Demo {
   public static void main(String[] args) {
      DoubleStream doubleStream = DoubleStream.of(39.8, 78.7, 64.7, 35.7, 47.8, 89.7, 28.7);
      System.out.println("Remaining Elements...");
      doubleStream.skip(5).forEach(System.out::println);
   }
}

Output

Remaining Elements...
89.7
28.7

Updated on: 30-Jul-2019

78 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements