提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
实现AutoCloseable
public class _01SimpleTryWithResource { /* from nowjava.com - 时代Java */ 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(