Caused by: java.lang.StringIndexOutOfBoundsException: index -1, length 0
时间: 2024-05-25 20:16:15 浏览: 104
java 字符串索引越界异常(StringIndexOutBounds)
5星 · 资源好评率100%
This error occurs when you are trying to access a character at a negative index or trying to access a character in an empty string.
For example, if you have a string "hello" and you try to access the character at index -1, you will get this error because the index must be between 0 and the length of the string minus 1.
To fix this error, you need to check the index before accessing the character to ensure it is within the valid range. You can also check if the string is empty before trying to access any characters.
阅读全文