public class CustomException extends Exception { //或者继承任何标准异常类
public CustomException() {} //用来创建无参数对象
public CustomException(String message) { //用来创建指定参数对象
super(message); //调用超类构造器
}
}
public class NegativeAgeException extends Exception {
//或者:extends Throwable
public NegativeAgeException() {}
public NegativeAgeException(String message) {
super(message);
}
}