报错:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 7 at java.lang.String.substring(String.java:1963) at Test.main(Test.java:4)
越界了 !!
代码:
public class Test {
public static void main(String[] args) {
String tom="123456";
String str=tom.substring(0,7);//括号里改成(0,6)就对了
System.out.println(str);
}
}