Collectors.toMap() keyMapper function question

Michael Nascimento misterm at gmail.com
Tue Oct 8 17:19:17 UTC 2013


Person::getLast()

Regards,
Michael

On Tue, Oct 8, 2013 at 2:01 PM, pfurbacher <pfurbacher at mac.com> wrote:
> I'm wondering how to more succinctly express the "keyMapper" function which
> is highlighted in the following:
>
>        List<Person> roster = ...;
>
>        Map<String, Person> map =
>             roster
>                 .stream()
>                 .collect(
>                     Collectors.toMap(
>                        *new Function<Person, String>() {
>                             public String apply(Person p) { return
> p.getLast(); }
>                          }*,
>                         Function.<Person>identity()));
>
> Thanks.
>
>
>
>
>
> --
> View this message in context: http://openjdk.5641.n7.nabble.com/Collectors-toMap-keyMapper-function-question-tp159371.html
> Sent from the OpenJDK General discussion mailing list archive at Nabble.com.



More information about the discuss mailing list