+1 Best Lance On Jul 1, 2014, at 8:34 PM, Stuart Marks <[email protected]> wrote:
> Please review this small patch to fix some errors in the examples in the docs > for java.util.stream.Collectors. Thanks to Raoul Urma for pointing these out. > > s'marks > > # HG changeset patch > # User smarks > # Date 1404256293 25200 > # Tue Jul 01 16:11:33 2014 -0700 > # Node ID 5b6a12d8a26e96052bc1c3ff787e8836fa4d64da > # Parent 71012e1b8534c481ba42a38e77fca0b90299628d > 8048989: small errors in Collectors examples > Reviewed-by: XXX > Contributed-by: [email protected] > > diff -r 71012e1b8534 -r 5b6a12d8a26e > src/share/classes/java/util/stream/Collectors.java > --- a/src/share/classes/java/util/stream/Collectors.java Mon Jun 16 > 17:52:21 2014 -0700 > +++ b/src/share/classes/java/util/stream/Collectors.java Tue Jul 01 > 16:11:33 2014 -0700 > @@ -729,7 +729,7 @@ > * person in each city: > * <pre>{@code > * Comparator<Person> byHeight = > Comparator.comparing(Person::getHeight); > - * Map<City, Person> tallestByCity > + * Map<City, Optional<Person>> tallestByCity > * = people.stream().collect(groupingBy(Person::getCity, > reducing(BinaryOperator.maxBy(byHeight)))); > * }</pre> > * > @@ -784,7 +784,7 @@ > * Comparator<String> byLength = Comparator.comparing(String::length); > * Map<City, String> longestLastNameByCity > * = people.stream().collect(groupingBy(Person::getCity, > - * reducing(Person::getLastName, BinaryOperator.maxBy(byLength)))); > + * reducing("", > Person::getLastName, BinaryOperator.maxBy(byLength)))); > * }</pre> > * > * @param <T> the type of the input elements > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 [email protected]
