Have a look at the code below
public class DivisionByZero3 {
public void division() {
int num1 = 10;
int num2 = 0;
try {
int t= num1/num2 ;
return;
}
catch (ArithmeticException e) { // (2)
System.out.println("Dealt with " + e);
System.out.println("catch.");
System.exit(1);
}
finally { // (3)
System.out.println("Finally done.");
}
System.out.println("Returning from division."); // (4)
}
public static void main(String args[]) {
new DivisionByZero3().division();
System.out.println("Returning from main.");
}
}
Here the finally block does not execute.
Is there any other way to ensure the finally
block does not execute ..