public class TestEx {
public static int test(int x){
int i=1;
try{
System.out.println("try 块中 10/x之前");
i = 10 /x;
System.out.println("try 块中10/x之后");
return i;
}catch(Exception e){
i =100;
System.out.println("catch块......");
}finally{
i =1000;
System.out.println("finally块");
}
return i;
}
public static void main(String avg[]){
System.out.println(TestEx.test(1));
System.out.println(TestEx.test(0));
}
}
返回结果:
try 块中 10/x之前
try 块中10/x之后
finally块
10
try 块中 10/x之前
catch块......
finally块
1000
为什么System.out.println 方法输出的值不同 ? |