package exception; import java.util.Scanner; public class EcmDef { Scanner Scanner = new Scanner(System.in); public static void main(String[] args) { try { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); int result = ecm(i,j); System.out.println(result); }catch (EcDef e){ System.out.println(e.getMessage()); }catch (ArithmeticException e){ System.out.println(e.getMessage()); }catch (ArrayIndexOutOfBoundsException e){ System.out.println("缺å°å½ä»¤è¡åæ°"); }catch (NumberFormatException e){ System.out.println("æ°æ®ç±»åä¸ä¸è´"); } } public static int ecm(int i ,int j) throws EcDef,ArithmeticException{ if (i<0 || j<0) throw new EcDef("è¾å ¥ä¸è½æ¯è´æ°"); if (j == 0) throw new ArithmeticException("餿°ä¸è½ä¸º0"); return i/j; } }