public class Test{
public static void main(String [] args){
int a, b;
float rst;
try {
if (args.length != 2) {
throw new IndexOutOfBoundsException();
}
a = Integer.parseInt(args[0]);
b = Integer.parseInt(args[1]);
if (b == 0) {
throw new ArithmeticException();
}
rst = (float) a / b;
System.out.println("result = " + rst);
} catch (IndexOutOfBoundsException e) {
System.out.println("输入参数不够或超出");
} catch (NumberFormatException e) {
System.out.println("非法参数");
} catch (ArithmeticException e) {
System.out.println("除零异常");
} catch (Exception e) {
e.printStackTrace();
}
}
}