构造函数能否抛出异常

可以

public class Test {
	public Test() {
		try{
			System.out.println(1/0);
		}catch(Exception e) {
			System.out.println("initial error");
		}
	}
	public static void main(String[]args) {
		try{
			Test t = new Test();
		}catch(Exception e) {
			System.out.println("error");
		}
}

http://bbs.csdn.net/topics/350143834  

posted on 2015-05-23 17:12  达达的spark  阅读(371)  评论(0)    收藏  举报

导航