Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8170573

Typo in documentation (examples) for class Collectors

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
           // Compute sum of salaries of employee
           int total = employees.stream()
                                .collect(Collectors.summingInt(Employee::getSalary)));

      should be:

           // Compute sum of salaries of employee
           int total = employees.stream()
                                .collect(Collectors.summingInt(Employee::getSalary));



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
           // Compute sum of salaries of employee
           int total = employees.stream()
                                .collect(Collectors.summingInt(Employee::getSalary));

      i.e. remove the last ')'
      ACTUAL -
           // Compute sum of salaries of employee
           int total = employees.stream()
                                .collect(Collectors.summingInt(Employee::getSalary)));

      i.e. one ')' too many



      URL OF FAULTY DOCUMENTATION :
      https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html

            martin Martin Buchholz
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: