首页 > 其他 > 详细

异常的捕获

时间:2016-04-24 15:30:33      阅读:244      评论:0      收藏: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();
}
}
}

技术分享

异常的捕获

原文:http://www.cnblogs.com/hell/p/5426921.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!