class Demo78
{
public static void main(String[] args) {
try{
div(4,0,null);
}catch(Exception e){
e.printStackTrace();
System.out.println("哎呀,出错了...");
}
}
public static void div(int a , int b,int[] arr) throws Exception,NullPointerException {
if(b==0){
throw new ArithmeticException();//抛出一个异常对象。
}else if(arr==null){
throw new NullPointerException();
}
int c = a/b;
System.out.println("结果:"+ c);
}
}
JAVA小练习78——抛出处理(throw,throws)
最新推荐文章于 2024-09-18 16:01:57 发布
由于未提供博客具体内容,无法生成包含关键信息的摘要。
340

被折叠的 条评论
为什么被折叠?



