Skip to content

Instantly share code, notes, and snippets.

@mike-neck
Created June 30, 2013 04:37
Show Gist options
  • Save mike-neck/5893871 to your computer and use it in GitHub Desktop.
Save mike-neck/5893871 to your computer and use it in GitHub Desktop.
AutoCloseableで遊んでた
public class AutoClosableExpression {
public static void main(String... args) {
try (LambdaClosable closable = () -> {
System.out.println("\(^o^)/オワタ");
}) {
closable.doSomething("(´・ω・`)");
} catch (Exception e) {
e.printStackTrace();
}
}
static interface LambdaClosable extends AutoCloseable {
default public void doSomething (String something) {
System.out.println("doing " + something);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment