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

📄 failingconstructor22.java

📁 JAVA编程思想第四版英文原版习题答案. pdf原版的
💻 JAVA
字号:
// exceptions/FailingConstructor22.java
// TIJ4 Chapter Exceptions, Exercise 22, page 488
/* Create a class called FailingConstructor with a constructor that might fail
* partway through the construction process and throw an exception. In main(), 
* write code that properly guards against this failure.
*/

public class FailingConstructor22 {
	Integer[] ia = new Integer[2];
	String s;
	FailingConstructor22(String s) throws Exception {
		ia[0] = 0;
		ia[1] = 1;
		ia[2] = 2;
		this.s = s; 
	}
	public static void main(String[] args) {
		try {
			FailingConstructor22 fc = new FailingConstructor22("hi");
		} catch(Exception e) {
			System.err.println("Caught Exception in main()");
			e.printStackTrace(System.err);
		} finally {
			
		}
	}	
}

⌨️ 快捷键说明

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