1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Merge pull request #1500 from JiaoZan/patch-1

fix: 书名修正
This commit is contained in:
Guide哥 2022-01-19 10:49:40 +08:00 committed by GitHub
commit d659762e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1301,7 +1301,7 @@ public class Test {
1. **适用范围(资源的定义):** 任何实现 `java.lang.AutoCloseable`或者 `java.io.Closeable` 的对象
2. **关闭资源和 finally 块的执行顺序:**`try-with-resources` 语句中,任何 catch 或 finally 块在声明的资源关闭后运行
《Effecitve Java》中明确指出
《Effective Java》中明确指出
> 面对必须要关闭的资源,我们总是应该优先使用 `try-with-resources` 而不是`try-finally`。随之产生的代码更简短,更清晰,产生的异常对我们也更有用。`try-with-resources`语句让我们更容易编写必须要关闭的资源的代码,若采用`try-finally`则几乎做不到这点。