throwdemo.java

来自「精通Java核心技术源代码」· Java 代码 · 共 22 行

JAVA
22
字号
public class ThrowDemo {
   public static void throwException() {
      	try {
        	throw new ArithmeticException();
      	}
     	catch ( ArithmeticException e ) {
        	System.out.println( "Exception caught indide method throwException." );
        	throw e;     // 抛出异常
     	}
   }
   
   public static void main( String args[] )
   {
  		try {
     	throwException();
     	}
     	catch ( ArithmeticException e ) {
       		System.out.println( "Exception recaught:" + e );
     	}   
   }	 
}

⌨️ 快捷键说明

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