try {
 } catch() {}
 finally {
     try {
     } catch() { }
     finally { }
 }

拥有上面的代码好吗?

最佳答案

是的,您可以这样做。

实际上,处理要正确关闭的流时甚至需要这样做:

InputStream in = /* ... */;
try {
} catch (...) {
} finally {
    try {
        in.close();
    } catch (...) {
    } finally {
    }
}

我看不到有任何不良做法

关于java - 将try catch最终块放在另一个finally块内,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6095664/

10-11 22:30
查看更多