![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LongStream skip() method in Java
The skip() method of the LongStream class 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 −
LongStream skip(long numEle)
Here, numEle is the number of elements to be skipped.
To use the LongStream class in Java, import the following package −
import java.util.stream.LongStream;
First, create a LongStrem and add some elements −
LongStream longStream = LongStream.range(5000L, 5025l);
Now, use the skip() method to skip the first n number of elements −
longStream.skip(15)
The following is an example to implement LongStream skip() method in Java −
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.range(5000L, 5025l); // skips the first 15 elements longStream.skip(15).forEach(System.out::println); } }
Output
5015 5016 5017 5018 5019 5020 5021 5022 5023 5024
Advertisements