In following code I want to understand the the behaviour of return statement.Finally block will always execute so this function will always return 30 ,but what is significance of return statement in try block.Does this return in try block return value to its caller, which will store this value in some stack and replaced when it see a return statement in finally block? or return in try block will call finally block?
public static int test() {
try {
return 10;// to whom this 10 is returned to?
} catch (Exception e) {
return 20;
}finally{
System.out.println("Finally");
return 30;
}
}
Thanks in advance.