为什么我们不在“抛出”中定义未经检查的异常。 java中的子句 [英] Why don't we define the unchecked exceptions in the "throws" clause in java

查看:64
本文介绍了为什么我们不在“抛出”中定义未经检查的异常。 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆