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

📄 ex11.java

📁 java编程思想第四版习题答案
💻 JAVA
字号:
// exceptions/Ex11.java
// TIJ4 Chapter Exceptions, Exercise 11, page 468
/* Repeat the previous exercise, but inside the catch clause, wrap g()'s
* exception in a RuntimeException.
*/
import static org.greggordon.tools.Print.*;

class GException extends Exception {
	GException(String s) { super(s); }
}

public class Ex11 {
	static void f() {
		try {
			g();
		} catch(GException ge) {
			println("Caught GException in f try");
			ge.printStackTrace();
			throw new RuntimeException(ge);
		}
	}
	static void g() throws GException {
		throw new GException("from g()");
	}
	public static void main(String[] args) {
		f();
	}
}



⌨️ 快捷键说明

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