DoubleStream skip() method in Java

Java 8Object Oriented ProgrammingProgramming

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
raja
Published on 27-Mar-2019 14:41:37
Advertisements