读书人

为啥String的substring(int,int)方法声

发布时间: 2013-09-06 10:17:17 作者: rapoo

为什么String的substring(int,int)方法声明中没有throws IndexOutOfBoundsException
String的substring(int,int)方法是会抛出IndexOutOfBoundsException异常的,
但是为什么该方法的声明中没有throws IndexOutOfBoundsException呢?

[解决办法]
这是运行时异常,这是能够通过代码带避免的 不需要throws
[解决办法]
因为IndexOutOfBoundsException是RuntimeException的子类,属于运行时异常,不需要声明。
[解决办法]
因为是java.lang.RuntimeException异常。

读书人网 >J2SE开发

热点推荐