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 ·
1328 阅读 ·
0 评论