Java custom exception

New Exception class inherits CustomException

/ ** 
 * 2019-07-30 ON by the Create 
 * custom class should extend Exception 
 * @author LSW
  * / 
public  class customException the extends Exception {
     public   customException () { 

    } 
    / ** 
     * super parent by calling a reference to the parent super the method or attribute class. . . , This is itself inside the 
     * parent of this instance refers to the inside of Exception Exception (method) ctrl + b back to the current page in which shortcuts? 
     * * / 
    Public customException (String msg) {
         Super (msg); 
    } 

    / ** 
     * throws an exception thrown external use attackHero methods need to capture abnormal 
     * * / 
    public  void attackHero (int Val) throws customException {
         IF (Val == 0 ) {
             the throw  new new customException ( "throw a custom exception" ); 
        } 
    } 

}

 

Insist on learning every day --java 

 

Guess you like

Origin www.cnblogs.com/y112102/p/11275227.html