Why does it gives such errors? Is it not possible to write some statements after continue statement? I agree, they will not be executed, but still... Well, the for loop's iteration expression is always executed inspite of writing a continue statement, right? Why is it allowed for this statement and why not for the statements written after continue statement?
your question is not so clear to understand where your doubt is, about continue- it skips rest of the statements existed after it and just continue next iteration of the for loop. I suggest you to understand the continue first
still I can give you a simple sample of code why the statements are not reachable. this is to understand how compiler looks the flow
see the foll code
if you compile above program it gives you the foll error
the reason is, compiler doesn't know what value I am going to give as argsat runtime. it thinks like if I give 1 at runtime, it is fine it satisfies if condition assigns k by 1 and prints it. if I give other than 1 as args then there is no value assigned to k still trying to print it. in this case it throws the possible error
compiler predicts at compile time itself and intimates user about possibility of the error.
in the same way, if continue exists in the flow every time it goes to next iteration of the inner for loop once it expires it executes outer for loop. it never reaches the statements existed after continue.
You firghten me terribly. I would like to go home now. Here, take this tiny ad: