自定义异常提问
public class DrunkException extends Exception {
public DrunkException(){
}
public DrunkException(String message){
super(message);
}
老师讲的自定义代码中 请问super(message)这个是什么意思?
public class DrunkException extends Exception {
public DrunkException(){
}
public DrunkException(String message){
super(message);
}
老师讲的自定义代码中 请问super(message)这个是什么意思?
2016-07-22
public class test { public static void main(String[] args) { test result=new test(); result.compute(); } public class DIYException extends Exception { String message; public DIYException(String str) { message = str; } public String getmessage() { return message; } } public void div(int one, int two) throws DIYException { if (two == 0) throw new DIYException("除数不能为0"); else System.out.println("结果为" + one / two); } public void compute() { try{div(5, 0);} catch (DIYException e) {System.out.println(e.getmessage());} } }
DIYException为自定义异常处理
举报