62,614
社区成员
发帖
与我相关
我的任务
分享
package Exception;
public class Test4 {
public int aa(int a,int b) throws Exception{
a=0;
b=0;
int n=a/b;
if(b==0){
throw new Exception("后者参数为0");
}else
System.out.println(n);
return n;
}
public static void main(String[] args) {
Test4 a=new Test4();
try {
a.aa(3,0); //为什么这里第二个参数是0却没有打印出抛出的Exception.
} catch (Exception e) {
System.out.println(e);
}
}
} //初学有点不大明白 希望大侠们指点下