0

I'm getting StringIndexOutOfBoundsException when I try to reasign the value of a variable. protString = protString.substring(newRPos+1, input.length()); I understand that this is something I would rather not do... but as I don't know the index of newRPos I can't think of another way to iterate.

Thanks

Edited by peter_budo: Correcting code tags

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by masijade
0

Then also check with if (newRPos < protString.length) . Also, is there any guarantee that input.length() is going to be larger than newRPos, as both of those are indexes (i.e. a start index and an end index) not a start and length, and I don't know how substring reacts if the end index is smaller than the start index..

1

... I don't know how substring reacts if the end index is smaller than the start index..

API doc states:

Throws: IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.

0

API doc states:

Thanks. That was just me being too lazy to look it up myself, and hoping the OP would figure out to do that. ;-)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.