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

Minor doc problems in Comparator and Map

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2
    • core-libs


      1) Comparator:

         "A class's natural ordering is said to be consistent with equals if
        and only if (e1.compareTo((Object)e2)==0) has the same boolean value
        as e1.equals((Object)e2) for every e1 and e2 of class C."

        This part of the spec should be clarified as follows:

        A class's natural ordering is said to be consistent with equals if
        and only if (e1.compareTo((Object)e2)==0) has the same boolean value
        as e1.equals((Object)e2) for every e1 and e2 of class C for which the
        former expression is defined (i.e., does not thrown an exception).

      2) Comparator:

          For example, if one adds two keys a and b such that
          (a.equals((Object)b) && c.compare((Object)a, (Object)b) != 0)
          to a sorted set with comparator c, the second add operation
          will return false (and the size of the sorted set will not
          increase) because a and b are equivalent from the sorted
          set's perspective.
          
      Typo. Should be:

          (!a.equals((Object)b) && c.compare((Object)a, (Object)b) == 0)

      3) Map: It would be convenient for Map.entrySet to @see Map.Entry.


          

            jjb Josh Bloch (Inactive)
            jjb Josh Bloch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: