【发布时间】:2019-03-08 11:15:25
【问题描述】:
在课堂上,我们使用此代码通过整数流生成斐波那契数列。 有人可以向我解释一下 .map() 函数在这段代码中的作用吗?
public class fibStream {
public static Stream<Integer> getFibStream() {
return Stream.iterate(new Integer[] {0,1}, s -> new Integer[]{s[1], s[0] + s[1]})
.map(s -> s[0]); //what is .map() doing here?
}
}
【问题讨论】:
-
你试过阅读java文档吗?
标签: java loops dictionary java-stream