为了账号安全,请及时绑定邮箱和手机立即绑定

下面的异常程序哪里出错?

下面的异常程序哪里出错?

qq_丘比特_0 2016-04-10 14:14:18
class  FuShuException   extends   RuntimeException{ FuShuException (String  msg) { super(msg); }}class  Demo{ int  div(int a, int  b)throws   Exception//throws  ArithmeticException { if(b<0) throw  new   Exception("出现了除数为负数了"); if(b==0) throw  new   ArithmeticException("被零除啦"); return  a/b; }} class   ExceptionDemo4 { public   static  void  main(String[]  args) { Demo  d=new  Demo(); int  x=d.div(4,-9);System.out.println("x="+x);System.out.println("over"); } }   
查看完整描述

3 回答

?
晨光3138270

TA贡献1条经验 获得超0个赞

去RuntimeException副类找找原因

查看完整回答
反对 回复 2016-04-10
?
waste_time

TA贡献43条经验 获得超16个赞

你抛出了异常,需要catch一下,或者用throws声明啊

查看完整回答
反对 回复 2016-04-10
  • 3 回答
  • 0 关注
  • 1445 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信