try-with-resource替代try-catch-finally,使你的Java编写更优美。
try-with-resource替代try-catch-finally估计一大半人还在使用try-catch-finally关闭资源吗,JDK7就可以引用的try-with-resource。简洁明了实现了java.lang.AutoCloseable接口public class Resource2 implements AutoCloseable{ public void run(){ throw new RuntimeException("run2 fa...
原创
2020-08-14 22:35:28 ·
1349 阅读 ·
0 评论