Java 中的 IntStream rangeClosed() 方法
IntStream 类中的 rangeClosed() 类通过 1 的递增步长从 startInclusive 返回一个按顺序排列的 IntStream,一直到 endInclusive。这包括 startInclusive 和 endInclusive 值。
语法如下
static IntStream rangeClosed(int startInclusive, int endInclusive)
其中,startInclusive 是包括第一个值的,而 endInclusive 是指示最后一个值的值。要在 Java 中使用 IntStream 类,请导入以下包
import java.util.stream.IntStream;
以下示例实现 Java 中的 IntStream rangeClosed() 方法
示例
import java.util.stream.IntStream;
public class Demo {
public static void main(String[] args) {
IntStream intStream = IntStream.rangeClosed(15, 25);
intStream.forEach(System.out::println);
}
}输出
15 16 17 18 19 20 21 22 23 24 25
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP