February 2014
Beginner
1248 pages
62h 25m
English
You previously used map operations to perform calculations on int values and to convert Strings to uppercase letters. In both cases, the resulting streams contained values of the same types as the original streams. Figure 17.13 shows how to map objects of one type (Employee) to objects of a different type (String). Lines 77–81 perform the following tasks:
• Line 77 creates a Stream<Employee>.
• Line 78 maps the Employees to their last names using the instance method reference Employee::getName as method map’s Function argument. The result is a Stream<String>.
• Line 79 calls Stream method distinct on the Stream<String> to eliminate any duplicate String objects in a Stream<String>.
• Line 80 ...
Read now
Unlock full access