java.lang.StringIndexOutOfBoundsException: 字符数组越界,操作字符串时试图取大于字符串长度的字符
此异常由 String 方法抛出,指示索引或者为负,或者超出字符串的大小。
对诸如 charAt 的一些方法,当索引等于字符串的大小时,也会抛出该异常。
”并不能说明String有长度限制
Java API指出StringIndexOutOfBoundsException异常
Thrown by 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。
上面的错误是因为
String.length()<10;
而你又要取index>=10的字符从而抛出上面异常
String其实是没有限制的,而是当String太大了,超过JVM的自身的内存后会抛出
java.lang.OutOfMemoryError错误
String是没有长度限制的,而是有JVM的内存限制了String的长度
在dayworker的blog中还提到