Multiple returns: Which one sets the final return value?
- by DR
Given this code:
String test() {
try {
return "1";
} finally {
return "2";
}
}
Do the language specifications define the return value of a call to test()? In other words: Is it always the same in every JVM?
In the Sun JVM the return value is 2, but I want to be sure, that this is not VM-dependant.