
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
LongStream.range() Method in Java
The range() method of the LongStream class in Java returns a sequential ordered LongStream from startInclusive to endExclusive by an incremental step of 1. This is inclusive of the initial element and exclusive of the last element.
The syntax is as follows:
static LongStream range(long startInclusive, long endExclusive)
Here, startInclusive is the first value, whereas the endExclusive is the last.
To use the LongStream class in Java, import the following package:
import java.util.stream.LongStream;
The following is an example to implement LongStream range() method in Java:
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.range(20L, 25L); longStream.forEach(System.out::println); } }
Output
20 21 22 23 24
Advertisements