看板 java 關於我們 聯絡資訊
在書上讀到拋出例外,有一種是指定method拋出 書上範例如下 public class app13_6 { public static void aaa(int a,int b) throws ArithmeticException { int c; c=a/b; System.out.println(a+"/"+b+"="+c); } public static void main(String args[]) { try { aaa(4,0); } catch(ArithmeticException e) { System.out.println(e+" throwed"); } } } 書上說第三上要定義此method所有可能的例外,但我把throws ArithmeticException 刪除,執行結果一模一樣,那這樣定義有什麼意義呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.217.109.254
slalala:讓人看的到她可能拋出此EXCEPTION 03/16 01:21
slalala:不只如此 你試試看SQLEXCEPTION的範例 多包個幾層METHOD看 03/16 01:24