1、自定义异常类
//自定义异常类
public class AlreadyClosedException extends IllegalStateException {
public AlreadyClosedException(String message) {
super(message);
}
}
//使用
if (analyzer.storedValue == null) {
throw new AlreadyClosedException("this Analyzer is closed");
}
public class IndexOutOfBoundsException extends RuntimeException { public IndexOutOfBoundsException() { super(); } public IndexOutOfBoundsException(String s) { super(s); } }