Start or end index provided to substring method outside the range of String indices

java.lang.StringIndexOutOfBoundsException
Javadoc
Thrown by {@code String} methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the charAt method, this exception also is thrown when the index is equal to the size of the string. @author unascribed @see java.lang.String#charAt(int) @since JDK1.0
at java.lang.String.substring
(source)

Typical Exception Messages

  1. String index out of range: -1
  2. String index out of range: -2
  3. String index out of range: 1
  4. <No message>
  5. String index out of range: -5
  6. String index out of range: 2
  7. String index out of range: -3
  8. String index out of range: -4
  9. String index out of range: -9
  10. String index out of range: -6

Specific cases

Solution

rp, 3 years ago

Ensure that the start and end indices for the substring are within range of the String's start and end indices

External results for this pattern (2393)

  1. Ivan-Veselovvia GitHub1 day ago
    String index out of range: -9
    Show stack trace
  2. pejovicavia GitHub2 days ago
    String index out of range: 5
    Show stack trace
  3. sxhyavia GitHub3 days ago
    String index out of range: -3
    Show stack trace
  4. devel-bobmvia GitHub3 days ago
    String index out of range: -1
    Show stack trace
  5. p-a-s-c-a-lvia GitHub3 days ago
    String index out of range: -1
    Show stack trace
  6. p-a-s-c-a-lvia GitHub3 days ago
    String index out of range: -1
    Show stack trace
  7. andyzhouhvia GitHub3 days ago
    String index out of range: -10
    Show stack trace
  8. tonilopezmrvia GitHub4 days ago
    String index out of range: -1
    Show stack trace
  9. jarWorkervia GitHub4 days ago
    String index out of range: 15
    Show stack trace
  10. srempfervia GitHub4 days ago