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

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

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

正在回答

3 回答

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

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下载
官方微信