为什么String的substring(int,int)方法声明中没有throws IndexOutOfBoundsException
String的substring(int,int)方法是会抛出IndexOutOfBoundsException异常的,
但是为什么该方法的声明中没有throws IndexOutOfBoundsException呢?
[解决办法]
这是运行时异常,这是能够通过代码带避免的 不需要throws
[解决办法]
因为IndexOutOfBoundsException是RuntimeException的子类,属于运行时异常,不需要声明。
[解决办法]
因为是java.lang.RuntimeException异常。