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

📄 exceptionpropagation.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
/**	Example that illustrates exception propagation. */
class ExceptionPropagation
{
	public static void main(String[] args)
	{
		Propagate instance = new Propagate();
		System.out.println("Start of program");
		instance.m1();
		System.out.println("End of program");
	}
}

class Propagate
{
	public void m1()
	{
		System.out.println("Start of m1");
		try
		{
			m2();
		} catch (ArithmeticException e)
		{
			System.err.println("Exception: " + e);
		}
		System.out.println("End of m1");
	}

	public void m2()
	{
		System.out.println("Start of m2");
		m3(0);
		System.out.println("End of m2");
	}

	public void m3(int d)
	{
		int n = 10;
		System.out.println("Start of m3");
		System.out.println("result = " + ( n / d));
		System.out.println("End of m3");
	}
}

⌨️ 快捷键说明

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