`
thrillerzw
  • 浏览: 146505 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java异常

    博客分类:
  • java
 
阅读更多

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);
    }
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics