--- old/src/share/classes/java/lang/String.java 2014-02-21 16:03:06.000000000 -0800 +++ new/src/share/classes/java/lang/String.java 2014-02-21 16:03:06.000000000 -0800 @@ -1671,11 +1671,11 @@ * Returns the index within this string of the first occurrence of the * specified substring. * - *
The returned index is the smallest value k for which: - *
- * If no such value of k exists, then {@code -1} is returned. + *- * this.startsWith(str, k) - *
The returned index is the smallest value {@code k} for which: + *
{@code + * this.startsWith(str, k) + * }+ * If no such value of {@code k} exists, then {@code -1} is returned. * * @param str the substring to search for. * @return the index of the first occurrence of the specified substring, @@ -1689,11 +1689,12 @@ * Returns the index within this string of the first occurrence of the * specified substring, starting at the specified index. * - *
The returned index is the smallest value k for which: - *
- * If no such value of k exists, then {@code -1} is returned. + *- * k >= fromIndex {@code &&} this.startsWith(str, k) - *
The returned index is the smallest value {@code k} for which: + *
{@code + * k >= Math.min(fromIndex, this.length()) && + * this.startsWith(str, k) + * }+ * If no such value of {@code k} exists, then {@code -1} is returned. * * @param str the substring to search for. * @param fromIndex the index from which to start the search. @@ -1780,11 +1781,11 @@ * specified substring. The last occurrence of the empty string "" * is considered to occur at the index value {@code this.length()}. * - *
The returned index is the largest value k for which: - *
- * If no such value of k exists, then {@code -1} is returned. + *- * this.startsWith(str, k) - *
The returned index is the largest value {@code k} for which: + *
{@code + * this.startsWith(str, k) + * }+ * If no such value of {@code k} exists, then {@code -1} is returned. * * @param str the substring to search for. * @return the index of the last occurrence of the specified substring, @@ -1798,11 +1799,12 @@ * Returns the index within this string of the last occurrence of the * specified substring, searching backward starting at the specified index. * - *
The returned index is the largest value k for which: - *
- * If no such value of k exists, then {@code -1} is returned. + *- * k {@code <=} fromIndex {@code &&} this.startsWith(str, k) - *
The returned index is the largest value {@code k} for which: + *
{@code + * k <= Math.min(fromIndex, this.length()) && + * this.startsWith(str, k) + * }+ * If no such value of {@code k} exists, then {@code -1} is returned. * * @param str the substring to search for. * @param fromIndex the index to start the search from.