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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.210.147