IntStream范围(int startInclusive,int endExclusive) 以增量步骤1返回从startInclusive(包含)到endExclusive(独占)的顺序IntStream。
null
语法:
static IntStream range(int startInclusive, int endExclusive)
参数:
返回值: 整数元素范围的连续整数流。
例子:
// Implementation of IntStream range // (int startInclusive, int endExclusive) import java.util.*; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream IntStream stream = IntStream.range( 6 , 10 ); // Displaying the elements in range // including the lower bound but // excluding the upper bound stream.forEach(System.out::println); } } |
输出:
6 7 8 9
注: IntStream范围(intstartinclusive,intendexclusive)基本上就像for循环一样工作。可以按如下顺序生成一个等效的递增序列:
for (int i = startInclusive; i < endExclusive ; i++) { ... ... ... }
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END