异常
public static void main(String[] args) {
int a=1;
int b=0;
//假设要捕获多个异常:从小到大
try {
System.out.println(a/b);
}catch (Error error){
System.out.println("Error");
}catch (Exception e){//Exception主要分为两种1.运行时异常,2.非运行时异常
System.out.println("Exception");
}catch (Throwable throwable){
/*
Java中有个java.lang.Throwable类,
这个类是Java中所有异常和错误的基类。
Throwable下有两个大类那就是异常(Exception)和错误(Error)。
*/
System.out.println("Throwable");
}
}

浙公网安备 33010602011771号