📄 throwexceptiondemo.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 + -