首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

为啥String的substring(int,int)方法声明中没有throws IndexOutOfBoundsException

2013-09-06 
为什么String的substring(int,int)方法声明中没有throws IndexOutOfBoundsExceptionString的substring(int

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

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

热点排行