June 2017
Beginner
1296 pages
69h 23m
English
... and streams with an array of Strings.
Strings to UppercaseThe stream pipeline in lines 17–19
Arrays.stream(strings)
.map(String::toUpperCase)
.collect(Collectors.toList()));
displays the Strings in uppercase letters. To do so, line 17 creates a Stream<String> from the array strings, then line 18 maps each String to its uppercase version by calling String instance method toUpperCase on each stream element.
Stream method map receives an object that implements the Function functional interface, representing a one-parameter method that performs a task with its parameter then returns the result. In this case, we pass to map an unbound instance method reference of the form ClassName::instanceMethodName (String::toUpperCase). “Unbound” ...