public class demo02{
public static void main(String args[]){
double i=0,j=0,k=0;
try{
i=Double.parseDouble(args[0]);
j=Double.parseDouble(args[1]);
}catch(ArrayIndexOutOfBoundsException
e){
System.out.println("输入参数个数不对");
return;
}catch(NumberFormatException e){
System.out.println("参数类型不对");
return;
}
try{
if(j==0){
throw new ArithmeticException();
}else{
k=i/j;
System.out.println(k);
}
}catch(ArithmeticException e)
{
System.out.println("除数不能为0");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
时间: 2024-11-05 22:42:33