Java / Exception
Does return statement allow finally block to execute in Java?
Yes. The return statement executes the finally block.
public class FinallyReturn { public static void main(String[] args) { System.out.println("Value returned = " + myMethod()); } public static int myMethod() { try { return 0; } finally { return 1; } } }
Output: Value returned = 1
More Related questions...