extrace.java

来自「这是我最近自己做的一个JAVA程序,请各位多多指教.谢谢了」· Java 代码 · 共 36 行

JAVA
36
字号
public class ExTrace{
  public void methodA(int money)throws SpecialException{
      if(--money<=0) throw new SpecialException("Out of money");
  }
  public void methodB(int money)throws Exception{
     try{
        methodA(1);
     }catch(SpecialException e){
        System.out.println("---Output of methodB()---");
        System.out.println(e.getMessage());
        throw new Exception("Wrong");
     }
  }
  public static void main(String args[]){
     try{
        new ExTrace().methodB(1);
     }catch(Exception e){
        System.out.println("---Output of main()---");
        e.printStackTrace();
     }
  }
}






/****************************************************
 * 作者:孙卫琴                                     *
 * 来源:<<Java面向对象编程>>                       *
 * 技术支持网址:www.javathinker.org                *
 ***************************************************/

 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?