Possible Duplicate:
Java try-finally return design question
Consider the following method:
public boolean test() {
try {
return false;
} finally {
return true;
}
}
Why does it return true
? I know that the finally part is executed always, but should it first execute the try part and the return true and exit the method? Can someone explain me in simple words why Java exactly acts like this? I think it is very counter-intuitive.