设为首页 加入收藏

TOP

Java异常处理机制以及try-catch-finally-return执行顺序(二)
2014-11-24 12:00:07 来源: 作者: 【 】 浏览:107
Tags:Java 异常 处理 机制 以及 try-catch-finally-return 执行 顺序
sException");
return "return in catch arrayIndexOutOfBoundsException";
}catch(NullPointerException e){
System.out.println("nullPointerException");
return "return in catch";
}finally{
System.out.println("finally start try");
int[] a= {2};
for(int i=0 ; i<1;i++){//②
System.out.println(a[i]);
} www.2cto.com
System.out.println("finallyend end end");
System.out.println("finally");
//return "return of finally";
}
//return "end fuction";
}
}
①处i=1运行结果:
start try
2
try end
finally start try
2
finallyend end end
finally
return of try not finally
①处i=2运行结果:
start try
2
arrayIndexOutOfBoundsException
finally start try
2
finallyend end end
finally
return in catch arrayIndexOutOfBoundsException
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇java关于可变参数的使用 下一篇启动jenkins时,failed

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: