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

Incorrect documentation on Collectors.toMap

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u45
    • core-libs

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      The documentation makes reference to "Functions" when it should be "Function".


         * @apiNote
           * It is common for either the key or the value to be the input elements.
           * In this case, the utility method
           * {@link java.util.function.Function#identity()} may be helpful.
           * For example, the following produces a {@code Map} mapping
           * students to their grade point average:
           * <pre>{@code
           * Map<Student, Double> studentToGPA
           * students.stream().collect(toMap(Functions.identity(),
           * student -> computeGPA(student)));
           * }</pre>
           * And the following produces a {@code Map} mapping a unique identifier to
           * students:
           * <pre>{@code
           * Map<String, Student> studentIdToStudent
           * students.stream().collect(toMap(Student::getId,
           * Functions.identity());
           * }</pre>
           *


      REPRODUCIBILITY :
      This bug can be reproduced always.

            psandoz Paul Sandoz
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: