LongStream rangeClosed(long startInclusive, long endInclusive) example
Description
LongStream rangeClosed(long startInclusive, long endInclusive)
returns a sequential ordered LongStream from startInclusive (inclusive) to endInclusive (inclusive) by an incremental step of 1.
Syntax
rangeClosed
has the following syntax.
static LongStream rangeClosed(long startInclusive, long endInclusive)
Example
The following example shows how to use rangeClosed
.
import java.util.stream.LongStream;
/*from w ww .ja va2 s. c om*/
public class Main {
public static void main(String[] args) {
LongStream b = LongStream.rangeClosed(1L, 5L);
b.forEach(System.out::println);
}
}
The code above generates the following result.