【发布时间】:2013-01-09 11:59:27
【问题描述】:
【问题讨论】:
-
你到底想做什么???
-
好像是
java 7 try with resources
【问题讨论】:
java 7 try with resources
在 Java 7 中,所有实现 AutoCloseable 的类都可以与“try-with-resources”结构一起使用:
class Layout implements AutoCloseable { ... }
// Usage
try (Layout layout = new Layout()) {
// do stuff here
}
编辑:注意到你用“android”标记了这个问题。 Android 不支持 Java 7,因此您将无法在那里使用 try-with-resources。
【讨论】: