qui*_*tin 11 java exception-handling exception indexoutofboundsexception
我们应该使用哪些用例ArrayIndexOutOfBoundsException和`IndexOutOfBoundsException?
Rav*_*abu 17
IndexOutOfBoundsException异常:抛出,表明某种索引(如到一个数组,为一个字符串,或载体)超出范围.
ArrayIndexOutOfBoundsException,StringIndexOutOfBoundsException
是两个已经实现的类IndexOutOfBoundsException.
ArrayIndexOutOfBoundsException:抛出此异常表示已使用非法索引访问数组.索引为负数或大于或等于数组的大小.
StringIndexOutOfBoundsException:由String方法抛出,以指示索引为负数或大于字符串的大小.对于某些方法(如charAt方法),当索引等于字符串的大小时,也会抛出此异常.
IndexOutOfBoundsExceptionArrayIndexOutOfBoundsException是(在访问数组中的无效索引时抛出)和StringIndexOutOfBoundsException(在访问字符串中的无效索引时抛出)的超类。
IndexOutOfBoundsException当访问列表的无效索引时,会抛出基类本身的实例。
IndexOutOfBoundsException一些抛出方法或其子类的Javadoc包含基类。例如,当它实际抛出子类时,String.charAt被记录为抛出。IndexOutOfBoundsExceptionStringIndexOutOfBoundsException
| 归档时间: |
|
| 查看次数: |
7282 次 |
| 最近记录: |