谁能来帮我写1段么...
再次表示感谢...
再次表示感谢...


除数为0的自定义异常类,我写了一个……其实你自己的那个不也是么……
public class ExceptionTest {
public ExceptionTest(int i,int l) {
try {
if(l == 0)
throw new NewException(\"除数不能为0\");
} catch(NewException e) {
System.out.println(e.getMessage() + \"! 除数改为1\");
l = 1;
}
System.out.println(i + \" / \" + l + \" = \" + (i / l));
}
public static void main(String[] args) {
int i = 3,l = 0;
new ExceptionTest(i,l);
}
}class NewException extends Exception {
public NewException(String errorMessage) {
super(errorMessage);
}
}