码迷,mamicode.com
首页 > 其他好文 > 详细

构造函数能否抛出异常

时间:2015-05-23 18:18:08      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

可以

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  

构造函数能否抛出异常

标签:

原文地址:http://www.cnblogs.com/bmestar/p/4524580.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!