- Learn Selenium
- Unmesh Gundecha Carl Cocchiaro
- 93字
- 2021-06-24 13:25:39
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.