日期:2014-05-20  浏览次数:20695 次

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

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