programming-examples/java/_Basics/Try Finally.java
2019-11-15 12:59:38 +01:00

22 lines
545 B
Java

Try Finally
public class TryFinally {
public static void main( String[] args ) throws Exception {
// important to note that try, does not always need
// to be accompanied by a catch block
try {
// if an exception is raised the finally block is
// executed and the exception propogates out, hence
// note the Exception on the main method's throw clause
throw new Exception( "oopsy" );
}
finally {
System.out.println( "no worries, i'm always called" );
}
}
}