exceptiondemo4.java

来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 25 行

JAVA
25
字号
/**
*Another simple exception program using toString/return in catch block
*2004.12.25. xhcprince
*/

class exceptionDemo4
{
	public static void main(String args[])
	{
		try
		{
			int a=4,b=0,c;
			c = a/b;
			System.out.println("c = " + c);
		}

		catch(Exception e)
		{
			System.out.println(e.toString());
			System.out.println(e.getMessage());//pay attention to the difference on the above!

			return;
		}
	}
}

⌨️ 快捷键说明

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