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

Map.replace javadoc code snippet typo

    XMLWordPrintable

Details

    Backports

      Description

        A DESCRIPTION OF THE PROBLEM :
        Please refer to the link - https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#replace-K-V-V-
        Class - Map
        Method - default boolean replace(K key,
                                V oldValue,
                                V newValue)

        Actual: The example given for this method has a variable called 'value'.
        if (map.containsKey(key) && Objects.equals(map.get(key), value)) {
             map.put(key, newValue);
             return true;
         } else
             return false;

        Expected: The variable should be given as "oldValue"
        if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) {
             map.put(key, newValue);
             return true;
         } else
             return false;

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Please refer to the link - https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#replace-K-V-V-
        Class - Map
        Method - default boolean replace(K key,
                                V oldValue,
                                V newValue)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expected: The variable should be given as "oldValue"
        if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) {
             map.put(key, newValue);
             return true;
         } else
             return false;
        ACTUAL -
        Actual: The example given for this method has a variable called 'value'.
        if (map.containsKey(key) && Objects.equals(map.get(key), value)) {
             map.put(key, newValue);
             return true;
         } else
             return false;


        Attachments

          Issue Links

            Activity

              People

                ccleary Conor Cleary (Inactive)
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: