前段时间有朋友问我异常执行顺序问题,这里简单记录下哈。
 伪代码描述,当j=0和j=1,输出结果分别是什么?
int i = 0;
int j = 0或1;
try {
  j = i / j;
	System.out.println(i);
	return i++;
} catch (Exception e) {
	System.out.println(i);
	return ++i;
} finally {
	System.out.println(i);
}
talk is cheap, show me the code!
 当j=0时候,输出结果为
0
1

 当j=1时候,输出结果为
0
1

 总结:当j=0或j=1,结果都是一样,j=0先走catch再走finally。
 j=1,不走catch,最后走finally。
0
1

















