String index out of range: -2 code example
Example: String index out of range: 7
package com.yawintutor;
public class StringSubstringCharAt {
public static void main(String[] args) {
String str = "Bangalore";
String str2;
str2 = str.substring(3, 8);
System.out.println("Given String : " + str);
System.out.println("Output String : " + str2);
}
}