Home  >  Forum  >  Core Java
Post New Query

Difference between IntStream.rangeClosed() and IntStream.range() in Java 8



Asked on December 31, 2014
Hi,

What is difference between IntStream.rangeClosed() and IntStream.range() in Java 8.

Regards
Paramjeet





Replied on December 31, 2014
IntStream.rangeClosed() and IntStream.range() both generates incremental number by one from start to end point in java 8.

IntStream.rangeClosed(2,6) works as >= and  <=  and  produces 

2,3,4,5,6

IntStream.range(2,6) works as >= and  < and  produces same but does not include the last number 

2,3,4,5

Find the link for the sample example.




 


Write Answer








©2019 concretepage.com | Privacy Policy | Contact Us