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

(coll spec) Bug in "toArray" example for Interface "Collection"

XMLWordPrintable

    • b51
    • generic, x86
    • generic, windows_2000, windows_xp



      Name: rmT116609 Date: 03/27/2003


      A DESCRIPTION OF THE PROBLEM :
      Inside "toArray" method explanation exists an example that has a bug.

      http://java.sun.com/j2se/1.4/docs/api/java/util/Collection.html#toArray(java.lang.Object[])


      Presently, it is documented like:
      ...
      Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

           String[] x = (String[]) v.toArray(new String[0]);
      ...


      It should be:

      ...
      Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

           String[] x = (String[]) l.toArray(new String[0]);
      ...


      (Review ID: 183130)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: