为什么我们不在“抛出”中定义未经检查的异常。 java中的子句 [英] Why don't we define the unchecked exceptions in the "throws" clause in java
问题描述
- >为什么我们不在throws子句中定义未经检查的异常(RuntimeException),为什么不必在throw子句中定义Runtime Exception。
- >为什么必须从try块中调用方法来定义throws子句中的已检查异常..
示例:
公共add()抛出CheckedException {}
尝试{
add()}
catch(){}
我尝试过:
公共add()抛出CheckedException {}
尝试{
add()< br $>
}
catch(..){
}
=== ================
->Why don't we define the unchecked exception(RuntimeException) in the throws clause,why is it not mandatory to define the Runtime Exception in the throw clause.
->Why is it mandatory to make a call to the method from the try block which defines the checked exception in the throws clause..
Example:
Public add() throws CheckedException{}
try{
add()}
catch(){}
What I have tried:
Public add() throws CheckedException{}
try{
add()
}
catch(..){
}
===================
推荐答案
参见未经检查的例外 - 争议(The Java™Tutorials) [ ^ ]。
有人可以用简单的术语解释,我已经完成了非常教程了上面提到的一个。
简而言之,有人可以解释一下。
Can someone explain in simple terms,I have gone through very tutorial's the one above mentioned.
In a short can someone explain it.
这篇关于为什么我们不在“抛出”中定义未经检查的异常。 java中的子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!