bukudekong

工作中遇到 java.lang.StringIndexOutOfBoundsException ,查看网上资料,总结如下

 

1、异常定义:

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 的字符时,会抛出上面的异常

 

2、关于String使用

String是不可变类,每一步操作都会返回新的String变量,占用时间和内存空间;

如 : String = String + " b"; 

实际上是新创建了个String变量 

 

 

 

参考资料:

http://blog.chinaunix.net/uid-11361941-id-2880422.html

分类:

技术点:

相关文章:

  • 2021-09-14
  • 2021-12-03
  • 2019-08-24
  • 2021-10-22
  • 2022-01-07
  • 2021-08-22
  • 2021-06-02
  • 2021-05-18
猜你喜欢
  • 2021-08-07
  • 2021-11-08
  • 2021-10-19
  • 2021-10-24
  • 2021-09-10
  • 2021-11-02
  • 2021-08-21
相关资源
相似解决方案