最后在异常处理 [英] finally in exception handling
本文介绍了最后在异常处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
推荐答案
例如,如果你打开了一个文件,你应该在 finally
块,以确保它始终关闭;如果在 try
块中关闭它,早期的异常将导致执行直接跳转到 catch
块并跳过关闭文件。
For example, if you have opened a file, you should close it in the finally
block to ensure that it will always be closed; if you closed it in the try
block, an earlier exception would cause execution to jump straight to the catch
block and skip closing the file.
请参阅 Java教程了解更多详情。
这篇关于最后在异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文