I am confused about the flow of the exception statements.When I run this I get try and 3.I thought it should print Hello also.
If I include a code return 5 in the catch block the compiler shows an error saying System.out.println("Hello"); not reached.If it is because of the return 5; then why I am not getting this error with only the below code as if there is no exception the code after the finally block should be executed?Can anyone please help.
public class Test5 {
public static void main (
String args []) {
System.out.println(A());
}
public static int A(){
try{
int i,j,k;
i=4;j=2;
k=i/j;
System.out.println("try");
return 3;
}
catch(ArithmeticException e){}
finally{}
System.out.println("Hello");
return 4;
}
}