「Java」Exceptionクラスの継承を実装するサンプル

1.構文
public class クラス名 extends Exception {
//some code
}
2.サンプルコード

public class SampleException extends Exception {

     public SampleException(){
        super();
       }
       public SampleException(String s) {
          super(s);
       }
       public SampleException(String msg,Throwable e) {
         super(msg,e);
       }
}

3.利用方法

 try {
    //処理コード
  } catch(SampleException e) {
  
  }

 

Java

Posted by arkgame