package pkg7.pkg1;
public class Main {
public static void main(String[] args) {
System.out.println("計算開始");
try {
int i = Integer.parseInt(args[0]);
int j = Integer.parseInt(args[1]);
int temp = 0;
temp = i / j;
System.out.println("兩個數字相除結果:" + temp);
//補捉錯誤
} catch (ArithmeticException e) {
System.out.println("錯誤訊息為:" + e);
System.out.println("除數不可為0 ");
} catch (NumberFormatException e) {
System.out.println("數字轉換例外了**********");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("陣列超出的例外了************");
} finally {
System.out.println("無論是否出現例外,一定會執行這一段!");
}
System.out.println("計算結束");
}
}
