A RuntimeException
is thrown in try
block without being caught, while the finally
clause invokes System.exit()
.
Finally method always will be executed even in case of return statement in try block ,but in some cases where throwing Errors(Run time memory) in try block there is no guarantee finally block executed completely.
In your case finally block always executed and exception throws by main method from the JVM since you are not handle the exception.