RFR(XS): JDK-8048989 small errors in Collectors examples

Stuart Marks stuart.marks at oracle.com
Wed Jul 2 00:34:56 UTC 2014


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: raoul at urma.com

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




More information about the core-libs-dev mailing list