展开全部
1): throws ArithmeticException
2:)new
3:)ArithmeticException
代码块里抛异bai常使用du的zhi是throw 关键字dao, 方法回体抛异常使用的是throws 关键字
使用try catch 用于捕获抛出答的异常, 并试图进行处理
完整的参考代码public class TestThrow {
static int x = 0;
static int y = 0;
public static void divide() throws ArithmeticException { // 方法定义抛出异常
if (x != 0) {
y = 100 / x;
} else {
throw new ArithmeticException("除数不能为零!");//抛出异常
}
}
public static void main(String[] args) {
try {
divide();
} catch (ArithmeticException e) {//捕获方法抛出的异常,并在catch里打印出来
e.printStackTrace();
}
}
}