package exception.Demo01;
public class Test {
public static void main(String[] args) {
int a = 1;
int b = 0;
//假设要捕获多个异常: 从小到大!
try { //try监控区域
// System.out.println(a/b);
new Test().a();
} catch (Error e) { //catch 捕获异常
System.out.println("程序出现异常,变量b不能为0");
} catch(Exception e){
}catch(Throwable e){
}finally{ //处理善后工作
System.out.println("finally");
}
//finally 可以不要finally ,假设用于 IO流,资源,关闭
}
public void a(){
b();
}
public void b(){
a();
}
}