📄 exceptiondemo3.java
字号:
/**
*A simple exception handling example
*2004.12.25. xhcprince
*/
class ExceptionClass
{
String name = "Bob";
public void show()
{
System.out.println("name is: " + name);
}
}
class exceptionDemo3
{
public static void main(String args[])
{
try
{
int a=4,b=1,c;
c = a/b;
System.out.println("c = " + c);
ExceptionClass obj = null;//new ExceptionClass();
obj.show();
}
catch(ArithmeticException e)
{
System.out.println("Denominator can't be zero");
}
/*catch(NullPointerException e)
{
System.out.println("Null reference has been use to access a member");
}*/
catch(Exception e)
{
System.out.println("Unexpected error");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -