I couldn't find any explanation text that says anything like, "it doesn't compile of you return in both the try, catch and final block.".
finally block is always executed, so, a return statement in finally cannot be unreachable just because it is present in the finally block or because there is a return statement or an if/else statement in the try or catch blocks.
The rules of unreachable code are same for all types of blocks. So, a simple code like this:
Code: Select all
try{
return;
}catch(Exception e){
return;
}catch(RuntimeException e){ //this catch block is unreachable
return;
}
finally{
if(true ) return ;
else return;
return; //this is unreachable
}
will not compile.
If you can find the question that you think has a problem, let us know.