Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
LongStream rangeClosed() method in Java
The rangeClosed() 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 the last element.
The syntax is as follows −
static LongStream rangeClosed(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 rangeClosed() method in Java −
Example
import java.util.stream.LongStream;
public class Demo {
public static void main(String[] args) {
LongStream longStream = LongStream.rangeClosed(20L, 25L);
longStream.forEach(System.out::println);
}
}
Output
20 21 22 23 24 25
Advertisements
