- Trending Categories
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
IntStream rangeClosed() method in Java
The rangeClosed() class in the IntStream class returns a sequential ordered IntStream from startInclusive to endInclusive by an incremental step of 1. This includes both the startInclusive and endInclusive values.
The syntax is as follows
static IntStream rangeClosed(int startInclusive, int endInclusive)
Here, startInclusive is the value including the first value and endInclusive is the value indicating the last value. To work with the IntStream class in Java, import the following package
import java.util.stream.IntStream;
The following is an example to implement IntStream rangeClosed() method in Java
Example
import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.rangeClosed(15, 25); intStream.forEach(System.out::println); } }
Output
15 16 17 18 19 20 21 22 23 24 25
Advertisements