RFR: 8303648: Add String.indexOf(String str, int beginIndex, int endIndex)
Alan Bateman
alanb at openjdk.org
Fri Mar 10 12:59:18 UTC 2023
On Tue, 7 Mar 2023 14:44:32 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
> As a followup of [JDK-8302590](https://bugs.openjdk.org/browse/JDK-8302590), this issue covers the analogous case for a search of a string rather than a character.
src/java.base/share/classes/java/lang/String.java line 2626:
> 2624: * On {@link String}s {@code s} and a non-empty {@code str}, for example,
> 2625: * {@code s.indexOf(str, fromIndex, s.length())} would throw if
> 2626: * {@code fromIndex} were larger than the string length, or were negative.
In passing, I think it's more common to put the apiNote after the method description and before the param/return.
src/java.base/share/classes/java/lang/String.java line 2634:
> 2632: /**
> 2633: * Returns the smallest index of an occurrence of the specified substring
> 2634: * within the specified index range of {@code this} string.
It might be a bit more consistent with other methods to say "the index of the first occurrence". That will make it consistent with the proposed @return text too. Otherwise the proposed wording looks okay to me.
-------------
PR: https://git.openjdk.org/jdk/pull/12903
More information about the core-libs-dev
mailing list