/**
* 异常类:年龄不合法
*/
public class IllegalAgeException extends Exception{
//序列化版本号
private static final long serialVersionUID=1L;
//构造器
public IllegalAgeException() {
super();
}
public IllegalAgeException(String message) {
super(message);
}
public IllegalAgeException(Throwable cause) {
super(cause);
}
public IllegalAgeException(String message, Throwable cause) {
super(message, cause);
}
public IllegalAgeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
自定义异常的 注意事项:
(1)见名知意
(2)继承Exception(直接或间接)
(3)重新定义序列化版本号
(4)重写父类构造器