首页 > 编程语言 > 详细

5.27 java中try,catch,throw,throws,finally

时间:2014-06-07 04:24:22      阅读:380      评论:0      收藏:0      [点我收藏+]

http://blog.sina.com.cn/s/blog_4f1c99de0100tyty.html

 

try{
//代码区
}catch(Exception e){
//异常处理
}
代码区如果有错误,就会返回所写异常的处理。

 

首先要清楚,如果没有try的话,出现异常会导致程序崩溃。
而try则可以保证程序的正常运行下去。

Java的异常处理是通过5个关键字来实现的:try,catch,throw,throws,finally。JB的在线帮助中对这几个关键字是这样解释的:
Throws:  Lists the exceptions a method could throw.
Throw:   Transfers control of the method to the exception handler.
Try:    Opening exception-handling statement.
Catch:  Captures the exception.
Finally: Runs its code before terminating the program.

 

5.27 java中try,catch,throw,throws,finally,布布扣,bubuko.com

5.27 java中try,catch,throw,throws,finally

原文:http://www.cnblogs.com/liyuhui20093357/p/3755979.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!