1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* public class Test{
public static void main(String[] args){
int i=0;
try{
func();//区别就是该函数抛出的异常被封装了,外界不知道到底会不会发生该异常
System.out.println("i = " + i++);//所以这句话是有机会执行的
}catch(Exception e){
System.out.println("i = " + i++);
}
}
static void func() throws Exception{
throw new Exception();
}
}
*/
public
class
Test{
public
static
void
main(String[] args){
int
i=
0
;
try
{
throw
new
Exception();
System.out.println(
"i = "
+ i++);
//完全的废话,肯定不会被执行到
}
catch
(Exception e){
System.out.println(
"i = "
+ i++);
}
System.out.println(
"i = "
+ i++);
}
}
|
本文转自 小眼儿 博客园博客,原文链接:http://www.cnblogs.com/hujunzheng/p/3872643.html,如需转载请自行联系原作者