標簽:異常 ret divide 結果 創建 代碼塊 public finally turn
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; }
標簽:異常 ret divide 結果 創建 代碼塊 public finally turn
原文地址:https://www.cnblogs.com/mrchenyushen/p/15028211.html