工做中遇到 java.lang.StringIndexOutOfBoundsException ,查看网上资料,总结以下html
一、异常定义:java
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。
以 java.lang.StringIndexOutOfBoundsException: String index out of range: 10 异常举例, 当String.length()<10,而你又要取index>=10 的字符时,会抛出上面的异常ui
二、关于String使用spa
String是不可变类,每一步操做都会返回新的String变量,占用时间和内存空间;.net
如 : String = String + " b"; unix
其实是新建立了个String变量 code
参考资料:htm
http://blog.chinaunix.net/uid-11361941-id-2880422.htmlblog