Last active
December 19, 2015 21:49
-
-
Save tigawa/6023287 to your computer and use it in GitHub Desktop.
java7 クローズ処理を明示的に呼び出さない書き方
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AutoClose { | |
public static void main(String[] args) { | |
try (AutoCloseable a = new AutoClose().new AutoCloseable()) { | |
System.out.print("A"); | |
} catch (Exception e) { | |
System.out.print("B"); | |
} finally { | |
System.out.print("C"); | |
} | |
} | |
private class AutoCloseable implements java.lang.AutoCloseable { | |
public void close() throws Exception { | |
System.out.print("D"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment