异常的捕获
2016-04-24 13:58 bgd140201135 阅读(158) 评论(0) 编辑 收藏 举报class Maths{
public int div(String x,String y)throws NumberFormatException,
ArithmeticException{
int result=0;
try{
int numa=Integer.parseInt(x);
int numb=Integer.parseInt(y);
result=numa/numb;
}catch(Exception e){
throw e;
}
return result;
}
}
public class yicahngbuhuo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
if(args.length!=2){
System.out.println("程序运行出错!");
System.exit(1);
}
try{
Maths mm=new Maths();
System.out.println(mm.div(args[0],args[1]));
}catch(Exception e){
e.printStackTrace();
}
}
}
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步