⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rethrowexceptiondemo.java

📁 java入门经典教程 java入门经典教程 java入门经典教程
💻 JAVA
字号:
// 例 3.2.4 ReThrowExceptionDemo.java
class ReThrowException 
{
	public void test() throws Exception
	{	
		try
		{
		    throw new IllegalAccessException();
		}catch(Exception ne){
			System.out.println("Catch Exception in test()");
			throw ne;   // 再次将异常抛出
		}
	}
}
class  ReThrowExceptionDemo
{
	public static void main(String[] args) 
	{
		ReThrowException re = new ReThrowException();
		System.out.println("The program begin to run");
		try
		{
			re.test();
		}catch(IllegalAccessException ie){
			System.out.println("Catch IllegalAccessException:"+ie);
		}catch(Exception e){
			System.out.println("Catch Exception:"+e);
	    }finally{
			System.out.println("The program is clearing....");
		}
		System.out.println("The program is over");
	}
}

⌨️ 快捷键说明

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