
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
IntStream skip Method in Java
The skip() method of the IntStream class in Java returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.
The syntax is as follows
IntStream skip(long n)
Here, n is the number of elements to skip. The method returns the new stream.
Create an IntStream and add some elements within a range using range() method
IntStream intStream = IntStream.range(20, 40);
Now to skip some elements and only display the rest of them, use the skip() method
intStream.skip(15)
The following is an example to implement IntStream skip() method in Java. It skips 15 elements since we have set the parameter value of the skip() method as 15
Example
import java.util.*; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.range(20, 40); intStream.skip(15).forEach(System.out::println); } }
Output
35 36 37 38 39
Advertisements