Created
July 2, 2020 21:25
-
-
Save 911992/60b5997223c09850456cf3b66d71ac4b to your computer and use it in GitHub Desktop.
java try-with-resources AutoCloseable example
This file contains 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
/*@author https://github.com/911992*/ | |
class My_Closeable_Type implements AutoCloseable | |
{ | |
public static void main (String arg_args[]) | |
{ | |
try(My_Closeable_Type _ins = new My_Closeable_Type()){ | |
}/*will call close() automatically*/ | |
} | |
@Override public void close(){/*mind there is no exception in signature, so no need for catch*/ | |
System.out.println("Statement point 0"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment