0

How to generate IntStream using rangeClosed() and range()

Using IntStream.rangeClosed() and IntStream.range():

import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        IntStream.rangeClosed(1, 10)
                 .forEach(System.out::println);

        System.out.println("");

        IntStream.range(1, 10)
                 .forEach(System.out::println);
    }
}

Output:

1
2
3
4
5
6
7
8
9
10

1
2
3
4
5
6
7
8
9
add comment
Suggest a different solution or add another example