0
Hi, print statement after finally is showing unreachable statement error, but not showing in case after catch block.
Why is it so?
3 Respostas
+ 3
A finally statement doesn't catch exceptions thrown in the try block. Only catch statements can catch exceptions.
Therefore, System.out.println("4"); is never reached, since the try block always throws an uncaught exception.
Regarsds:stackoverflow
+ 2
out. print("inside infinite loop"); code can never be reached with. When the compiler compiles the whole body of code and make byte code according to your code, it smarter enough to detectsunreachable code and also dead code. So, immediate break in the for-loop makes unreachable otherstatements.
0
Yes, but it is not showing complition error when writing print statement after catch block. And showing when written after finally block. This all is happening inside a for loop with a break statement in a try block..? Pls explain.