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

(spec) String.indexOf(String, int) equation for return value is confusing

XMLWordPrintable

    • b78
    • x86
    • windows_2000, windows_xp

      Name: rmT116609 Date: 02/19/2003


      DESCRIPTION OF THE PROBLEM :
      Current String.indexOf(String, int) (as found at http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html#indexOf(java.lang.String,%20int), and within src.zip
      included with JDK 1.4.0_01) states that k is:

          k >= Math.min(fromIndex, str.length()) &&
      this.startsWith(str, k)

      Should state:
                k >= Math.min(fromIndex, this.length()) &&
      this.startsWith(str, k)

      If the current statement was true, then any searches for
      the empty string starting at any position would always
      return 0: (k >= Math.min(fromIndex, "".length()).


      (Review ID: 160826)
      ======================================================================

            iris Iris Clark
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: