抛出任何一个没被捕获的 Exception 都会中止程序的运行

解决方案 »

  1.   

    别让程序抛出例外,那样,会输出一堆提示的,你可以返回boolean型呀,如果false的话,就终止呀,很easy呀,!也可以在例外中写retrun 的!
      

  2.   

    多谢楼上指点,可以我需要捕获,Exception 因为我要进行一些处理,有没有其它办法?
      

  3.   

    class myException extends Exception {
    public myException(String ErrorString) {
    super(ErrorString);
    …………//这里进行你的一些处理
    }
    }public class myClass {
    public static void main(String args[]) {
    ………………
    try{
    if(这里写入需要进行一些处理的条件)
      throw new myException(这里输入需要显示的出错信息);
    }catch(Exception e){System.out.print(e.toString());}
    }
    }
      

  4.   

    sorry,要在处理完之后如果需要终止程序运行
    }catch(Exception e){System.out.print(e.toString());}
    -->
    }catch(Exception e){System.out.print(e.toString());System.exit(0);}