上QQ阅读APP看书,第一时间看更新
Stream.map()
Streams provide a map() method to map the elements of a stream into another form. We can map the elements into a new object. Let's take the previous example and convert the elements of languages list to uppercase, as shown here:
languages.stream().map(item -> item.toUpperCase());
This will map all elements that are strings in the language collection to their uppercase equivalents. Again, this doesn't actually perform the mapping; it only configures the stream for mapping. Once one of the stream processing methods is invoked, the mapping (and filtering) will be performed.