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

(coll spec) Collection toArray() does not specify empty collection behavior

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs

      Name: rmT116609 Date: 04/14/2004


      A DESCRIPTION OF THE PROBLEM :
      The API Javadoc for Collection toArray() does not specify empty collection behavior. Since the List API Javadoc references the Collection Javadoc, this should be mentioned.

      The Javadoc states that it "Returns an array containing all of the elements in this collection." However, the observed behavior seems that if a Collection (or, in my case, a List) is empty, it returns null.

      I'd hope the Javadoc should mention null, empty array, or explicitly undefined

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I'd hope the Javadoc should mention null, empty array, or explicitly undefined behavior for an empty collection or list
      ACTUAL -
      The Javadoc states that it "Returns an array containing all of the elements in this collection." However, the observed behavior seems that if a Collection (or, in my case, a List) is empty, it returns null.

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html#toArray()
      (Incident Review ID: 250281)
      ======================================================================

            martin Martin Buchholz
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: