I have read that finally block is always executed in Java. But I want to know if there is any conditions when finally is not executed.
When finally block is not executed in Java?
There are cases when finally block is not executed in Java program. Here are the cases when finally block is not executed:
If System.exit() called in the program.
When JVM crashes due to some reason.
If program is in non-terminating statement and it is stopped by killing the program
If OS kills Java process. In windows its through task manager. In linux its kill -9 command.
If there is system power faliure
Check Java tutorials.