java 异常问题

新手中的新手 新手中的新手 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
最近刚学异常产生疑问:
class weiLingException extends RuntimeException{
weiLingException(String s){
super(s);
}
}
class Text{
void show(int x)throws weiLingException {//这里的throws抛给谁
if(x==0){
throw new weiLingException("分母不能为0");//这里的throw又抛给谁
}
int s =3/x ;
System.out.println(s);
}
}
public class class1 {
public static void main(String[] args) {
Text t = new Text();
t.show(0);
}
}

...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
新手中的新手
Java SE 62,620 成员 307,251 内容