throwsdemo.java
来自「JAVA编程思想源代码 值得一下 很难找的」· Java 代码 · 共 27 行
JAVA
27 行
package chapter14;
public class ThrowsDemo {
public static void compute() throws ArithmeticException,
ArrayIndexOutOfBoundsException {
System.out.println("the method compute");
int[] x = new int[3];
for (int i = 0; i <= 3; i++) {
System.out.println(x[i]);
}
}
public static void main(String[] args) {
try {
compute();
} catch (ArithmeticException e) {
System.out.println("数学运算错误");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("数组越界错误");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?