public class UnrechableCode {
public static void main (String args[])
{
UnrechableCode uc=new UnrechableCode();
try
{
System.out.println(1/0);
}
catch(Exception e)
{
System.out.print("Inside Catch");
return ;
}
finally
{
System.out.println("Inside Finally");
//return;
}
System.out.println("TEST");
}
}
上記のコードで、Catch から return ステートメントを削除すると、finally ブロックの後のステートメントは実行されませんが、パーサーによって到達可能です。同じシナリオで、finally ブロックに return を書き込むと、同じステートメントにパーサーが到達できないため、前のケースでステートメントがパーサーに到達できる場合、ステートメントが実行されないのはなぜですか?