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.

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.