我们可以在catch块中再添加一个try块吗 [英] can we include the one more try block in the catch block
本文介绍了我们可以在catch块中再添加一个try块吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个关于Java的问题,我们可以在try块中包含try块.
谢谢,
Amol
Hi everybody,
I have one question about the java that can we include the try block in the catch block.
Thanks,
Amol
推荐答案
是的,请参考此 [ ^ ]
是的,您可以有另一个级联try/catch块.这是经常做的事.
您可能需要阅读更多有关它的信息: http://docs.oracle.com/javase/tutorial/essential/exceptions/ [ ^ ]
Yes, you can have another cascade try/catch blocks. It''s often done.
you might want to read more about it: http://docs.oracle.com/javase/tutorial/essential/exceptions/[^]
是的,您当然可以,请记住,您可以包装任何可能引发带有"try ... catch"块异常的代码,即使该代码位于"catch"块内.
捕获块可能包含引发异常的代码,因此您应捕获该异常以防止崩溃:)
这是一个谈论这个话题的话题:
exception-handling-try-catch-inside-catch [ ^ ]
最好的Reagards.
EL GAABEB.
Hi,
Yes of course you can, keep in mind that you can wrap any piece of code that could throw an exception with a "try...catch" block ... even if that was inside "catch" block.
Catch block could contain a piece of code that throw an exception so you should catch it to prevent a crash :)
here is a thread talking about this :
exception-handling-try-catch-inside-catch[^]
Best Reagards.
EL GAABEB.
这篇关于我们可以在catch块中再添加一个try块吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文