Pattern selector

Most relevant patterns first. Most helpful ones displayed. Click here to show all.

  1. String.substring() has thrown a StringIndexOutOfBoundsException
    Java Runtime
    8
    29
    23
  2. Start or end index provided to substring method outside the range of String indices
    Java Runtime
    302
    803
    195

Your stack trace compared to the selected pattern

Jump to solutionsExpand frames
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
    at java.lang.String.substring(String.java:1497)
    at java.lang.String.substring(String.java:1470)

Solution

rp3 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 (10)

  1. 843789via Oracle Community1 day ago
    String index out of range: 45
    Show stack trace
  2. nicolatimeusvia GitHub2 days ago
    String index out of range: -10
    Show stack trace
  3. CreeperHangvia GitHub2 days ago
    String index out of range: -1
    Show stack trace
  4. lightlikevia GitHub2 days ago
    String index out of range: -1
    Show stack trace
  5. bin4rym4gevia GitHub2 days ago
    String index out of range: 2
    Show stack trace
  6. zachbrvia GitHub2 days ago
    String index out of range: -279
    Show stack trace
  7. Patryk003via GitHub2 days ago
    String index out of range: -1
    Show stack trace
  8. musketyrvia GitHub2 days ago
    String index out of range: 5
    Show stack trace
  9. pedrorijo91via GitHub2 days ago
    String index out of range: -1
    Show stack trace
  10. smolavia GitHub4 days ago
    exception writing response
    Show stack trace