On Fri, 24 Feb 2023 15:32:34 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> 
wrote:

>> I simply extrapolated the behavior from `indexOf(int ch,int fromIndex), 
>> which has a similar note:
>> 
>>      * There is no restriction on the value of {@code fromIndex}. If it
>>      * is negative, it has the same effect as if it were zero: this entire
>>      * string may be searched. If it is greater than the length of this
>>      * string, it has the same effect as if it were equal to the length of
>>      * this string: {@code -1} is returned.
>
> This is the behavior of the underlying implementation as well.

Personally I would expect `string.substring(fromIndex, toIndex).indexOf(ch)` to 
behave isomorphically to `string.indexOf(ch, fromIndex, toIndex)`

-------------

PR: https://git.openjdk.org/jdk/pull/12600

Reply via email to