February 2014
Beginner
1248 pages
62h 25m
English
Lines 18–21 display the Strings in uppercase letters. To do so, line 19 creates a Stream<String> from the array strings, then line 20 calls Stream method map to map each String to its uppercase version by calling String instance method toUpperCase. String::toUpperCase is known as a method reference and is a shorthand notation for a lambda expression—in this case, for a lambda expression like:
(String s) -> {return s.toUpperCase();}
or
s -> s.toUpperCase()
String::toUpperCase is a method reference for String instance method toUpperCase. Figure 17.8 shows the four method reference types.
Fig. 17.8 | Types of method references.
Stream method map receives ...
Read now
Unlock full access