java异常中一个有趣的例子

时间:2014-04-11 16:52:52   收藏:0   阅读:445
public class Test {
	public static String output = "";

	public static void foo(int i) {
		try {
			if (i == 1)
				throw new Exception();
			output += "1";
		} catch (Exception e) {
			output += "2";
			return;
		} finally {
			output += "3";
		}
		output += "4";
	}

	public static void main(String[] args) {
		foo(0);
		System.out.println(output);
		foo(1);
		System.out.println(output);
	}
}
问输出结果是什么?

java异常中一个有趣的例子,布布扣,bubuko.com

原文:http://blog.csdn.net/worst_hacker/article/details/23375871

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!