Java 实例 - 链试异常
Java 教程
· 2019-02-11 11:11:36
以下实例演示了使用多个 catch 来处理链试异常:
Main.java 文件
public class Main {
public static void main (String args[])throws Exception {
int n=20,result=0;
try{
result=n/0;
System.out.println("结果为"+result);
}
catch(ArithmeticException ex){
System.out.println("发算术异常: "+ex);
try {
throw new NumberFormatException();
}
catch(NumberFormatException ex1) {
System.out.println("手动抛出链试异常 : "+ex1);
}
}
}
}
以上代码运行输出结果为:
发算术异常: java.lang.ArithmeticException: / by zero 手动抛出链试异常 : java.lang.NumberFormatException
点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html
The Sovereign Individual
James Dale Davidson、William Rees-Mogg / Free Press / 1999-08-26 / USD 16.00
Two renowned investment advisors and authors of the bestseller The Great Reckoning bring to light both currents of disaster and the potential for prosperity and renewal in the face of radical changes ......一起来看看 《The Sovereign Individual》 这本书的介绍吧!