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

📄 throwexceptiondemo.java

📁 java入门经典教程 java入门经典教程 java入门经典教程
💻 JAVA
字号:
// 例3.2.1 ThrowExceptionDemo.java
class ThrowException
{
	public void test(ThrowException te)
    {
		if ( te == null ) 
			throw new NullPointerException();
		else 
			System.out.println("This Object is not NULL");
    }
}
class ThrowExceptionDemo
{
	public static void main(String[] args)
    {
		ThrowException te = new ThrowException();
		ThrowException te_null = null;
        try
		{
			te.test(te);
			te.test(te_null);
		}catch(NullPointerException ne){
			System.out.print("Catch Exception: ");
			ne.printStackTrace();
		}
		System.out.println("The program is over");
    }
}

⌨️ 快捷键说明

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