chap7-4.txt
来自「清华大学出版社经典教材系列」· 文本 代码 · 共 25 行
TXT
25 行
// 程序7-4
public class ThrowException{
public static void Test( ) {
try{
int c[ ]=new int[10];
c[10]=0;
}catch(ArrayIndexOutOfBoundsException e) {
System.out.println("\t 数组下标越界!");
throw e; // 将该异常对象提交给main方法进行处理
// System.out.println("\t产生异常后!"); // 该行无法通过编译
}
}
public static void main(String args[ ]) {
try{
Test( );
}catch(IndexOutOfBoundsException e) { // 处理Test方法提交的异常
System.out.println("\t 下标越界!");
}finally{
System.out.println("\t 在finally块中!");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?