- 
    Bug 
- 
    Resolution: Duplicate
- 
     P4 P4
- 
    None
- 
    8
- 
        x86
- 
        other
- 
        Verified
                    A DESCRIPTION OF THE PROBLEM :
The example in the API Note is wrong, it doesn compile. The identity value is missing in the reduce method call.
Map<City, String> longestLastNameByCity
= people.stream().collect(groupingBy(Person::getCity,
reducing(Person::getLastName, BinaryOperator.maxBy(byLength))));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Map<City, String> longestLastNameByCity
= people.stream().collect(groupingBy(Person::getCity,
reducing("",Person::getLastName, BinaryOperator.maxBy(byLength))));
ACTUAL -
Map<City, String> longestLastNameByCity
= people.stream().collect(groupingBy(Person::getCity,
reducing(Person::getLastName, BinaryOperator.maxBy(byLength))));
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html#reducing-U-java.util.function.Function-java.util.function.BinaryOperator-
            
The example in the API Note is wrong, it doesn compile. The identity value is missing in the reduce method call.
Map<City, String> longestLastNameByCity
= people.stream().collect(groupingBy(Person::getCity,
reducing(Person::getLastName, BinaryOperator.maxBy(byLength))));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Map<City, String> longestLastNameByCity
= people.stream().collect(groupingBy(Person::getCity,
reducing("",Person::getLastName, BinaryOperator.maxBy(byLength))));
ACTUAL -
Map<City, String> longestLastNameByCity
= people.stream().collect(groupingBy(Person::getCity,
reducing(Person::getLastName, BinaryOperator.maxBy(byLength))));
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html#reducing-U-java.util.function.Function-java.util.function.BinaryOperator-
- duplicates
- 
                    JDK-8048989 small errors in Collectors examples -           
- Closed
 
-