Java异常之finally和多重捕获·11
2021-07-21 14:55
                         标签:异常   ret   divide   结果   创建   代码块   public   finally   turn         Java异常之finally和多重捕获·11 标签:异常   ret   divide   结果   创建   代码块   public   finally   turn    原文地址:https://www.cnblogs.com/mrchenyushen/p/15028211.html
try{
    //可能发生异常的代码块
}catch(ExceptionName1 e1){
    // 出异常时候处理
}catch(ExceptionName2 e2){
    // 出异常时候处理
}
try{
    // 可能发生异常的代码
}catch(Exception e){
    // 出现异常时的处理
}finally{
    //肯定执行的代码
}
try{
   // 可能发生异常的代码块 
}finally{
    // 肯定执行的代码
}
public static int divide(int num1, int num2) {
    try {
        int result = num1 / num2;
        return result;
    } catch (Exception e) {
        System.out.println("出异常了......");
    } finally {
        System.out.println("finally代码块被执行了......");
        return -2;
    }
文章标题:Java异常之finally和多重捕获·11
文章链接:http://soscw.com/index.php/essay/106811.html