当前位置: 技术问答>java相关
throws关键字是什么意思?
来源: 互联网 发布时间:2015-03-23
本文导语: 我看了看帮助 ,没看明白,请指教! | 抛出异常,让调用者捕获异常 | So,how do we know that some method throws an exception that we have to catch? Just as a method must specify what ty...
我看了看帮助 ,没看明白,请指教!
|
抛出异常,让调用者捕获异常
|
So,how do we know that some method throws an exception that we have to catch?
Just as a method must specify what type and how many arguments it accepts and what is returned,the exception that a method can throw must be specified.the list of thrown exceptions is part of a method's public interface.The throws keyword is uned as follows to list the exceptions that a method can throw:
void myFuntion() throws MyException1,MyException2{
//code for the method here
}
Just as a method must specify what type and how many arguments it accepts and what is returned,the exception that a method can throw must be specified.the list of thrown exceptions is part of a method's public interface.The throws keyword is uned as follows to list the exceptions that a method can throw:
void myFuntion() throws MyException1,MyException2{
//code for the method here
}
|
抛出异常,常和Try搭配使用,也可单独使用
|
抛出异常,让调用者捕获异常。
|
抛出例外 (此例外不再考虑,或其他程序处理)
|
http://www.csdn.net/Expert/topic/481/481763.shtm
|
当有异常出现时,本身不做处理,抛出异常,让调用者捕获异常