【发布时间】:2016-06-10 07:14:53
【问题描述】:
假设我有一个
String temp = "abcd";
System.out.println(temp.substring(0,4)); // out of bound, no error
System.out.println(temp.substring(0,5)); // out of bound, error
为什么?
【问题讨论】:
-
第二个参数是endindex但最后一个索引是3
-
不需要重复,但这可能会让你感兴趣:stackoverflow.com/a/33600969/1393766
标签: java arrays string indexoutofboundsexception