IntStream rangeClosed(int startInclusive, int endInclusive) example
Description
IntStream rangeClosed(int startInclusive, int endInclusive)
returns an IntStream from startInclusive (inclusive) to endInclusive (inclusive) by an incremental step of 1.
Syntax
rangeClosed
has the following syntax.
static IntStream rangeClosed(int startInclusive, int endInclusive)
Example
The following example shows how to use rangeClosed
.
import java.util.stream.IntStream;
//ww w . ja v a2 s. co m
public class Main {
public static void main(String[] args) {
IntStream i = IntStream.rangeClosed(1,7);
i.forEach(System.out::println);
}
}
The code above generates the following result.