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

The TreeSet javadoc wrongly claims equals method will be used to test equality

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs

      A DESCRIPTION OF THE PROBLEM :
      The TreeSet javadoc claims that the add method:
      "More formally, adds the specified element e to this set if the set contains no element e2 such that (e==null ? e2==null : e.equals(e2)). If this set already contains the element, the call leaves the set unchanged and returns false."

      This is not correct, since only the comparable interface is used to assert equality in the source code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A reference to the comparable interface being used to assert equality instead of the equals method.
      ACTUAL -
       More formally, adds the specified element e to this set if the set contains no element e2 such that (e==null ? e2==null : e.equals(e2)). If this set already contains the element, the call leaves the set unchanged and returns false.

      URL OF FAULTY DOCUMENTATION :
      http://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html#add(E)

            mduigou Mike Duigou
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: