提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
简单尝试资源
/* N o w J a v a . c o m - 时 代 Java 提 供 */ public class _01SimpleTryWithResource { public static void main(String[] args) { try (Test test = new Test();) { test.show(); // No Need to Call it // test.close(); } catch (Exception e) { System.out.println(e.toString()); } finally { } } } class Test implements AutoCloseable { /* *来 自 N o w J a v a . c o m */ @Override public void close() throws Exception { System.out.println(