On Fri, 24 Feb 2023 15:26:35 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/String.java line 2467: >> >>> 2465: * >>> 2466: * <p>As consequence of these rules, if {@code fromIndex} is >>> greater than >>> 2467: * or equal to {@code toIndex}, then {@code -1} is returned. >> >> Are there other examples in String where the equivalent of fromIndex > >> toIndex doesn't throw? > > 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. ------------- PR: https://git.openjdk.org/jdk/pull/12600