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

“喝醉了”异常是老师之前就定义好的异常么?为何我自己写的时候,提示“DrunkException cannot be resolved to a type”?

“喝醉了”异常是老师之前就定义好的异常么?为何我自己写的时候,提示“DrunkException cannot be resolved to a type”?

正在回答

2 回答

是老师自己定义的,要想使用需要自己定义:

class DrunkException extends Exception{
    public DrunkException(){
        super();
    }
    
    public DrunkException(String str){
        super(str);
    }
}


1 回复 有任何疑惑可以回复我~
#1

吼哈吼吼

谢了~
2016-08-15 回复 有任何疑惑可以回复我~

自定义异常继承Exception,使用的时候,通过关键字throw 抛出,或者通过throws交给上一级出来,捕获通过trycatch语句,捕获异常。如果不在同一个包内,需要import

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

“喝醉了”异常是老师之前就定义好的异常么?为何我自己写的时候,提示“DrunkException cannot be resolved to a type”?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号