用于 int 范围的 Java 8 IntStream?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28313726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 05:59:22 来源:igfitidea点击:
Java 8 IntStream for an int range?
提问by tmn
Is there a way to create an IntStream
for a range of ints?
有没有办法IntStream
为一系列整数创建一个?
Like if I wanted to stream values 1 to 1000, I could invoke some IntStream
static factory to stream that range?
就像如果我想传输 1 到 1000 的值,我可以调用一些IntStream
静态工厂来传输该范围?
IntStream.forRange(1, 1000).forEach(//do something...
采纳答案by tmn
Never mind, I don't know why I missed it in the API documentation after reading it several times...
没关系,我不知道为什么我看了几遍 API 文档中遗漏了它......
IntStream.range(1,1000)