【发布时间】:2015-01-07 12:56:53
【问题描述】:
我正在阅读有关 java 8 的 Stream 机制及其不同方法的信息,我想尝试用它来映射和排序字符串数据,但我无法理解 Stream 文档。
来自map 方法的 Java 8 文档
<R> Stream<R> map(Function<? super T,? extends R> mapper)
Returns a stream consisting of the results of applying the given function to the elements of this stream.
以及过滤方法,
Stream<T> filter(Predicate<? super T> predicate)
Returns a stream consisting of the elements of this stream that match the given predicate.
谁能给出任何真实的例子来使用 Stream 类的 filter 和 map 方法?
【问题讨论】:
-
谷歌搜索结果全无?
-
class documentation 已经举了一个例子。