when a continue statement is executed in a the update statement always executes. Explained in Fewer than 140 Characters
An example of this is when you update a continue statement. The continue statement is executed by the update statement, which is only executed if the variable is true. But then again, we can continue in another statement, which I like to call “self-aware.
The update statement is a really powerful statement, because it provides the developer a way to update the behavior of a variable from within another code snippet that is not executed until the end of the current run of execution. It’s like a little bit of meta-cognition going on in the background of your computer. It turns out that the continue statement is actually something that we can use as a self-aware statement.
The developer that wrote the Continue statement in Java had to know that the Java language only allows statements that are terminated by a semicolon. So in the case of the Continue statement, which is an important control structure, the developer had to modify it to terminate the statement by a semicolon. But it still works.
The problem is, if you use the continuation of a return statement to execute a continue statement, then you can inadvertently execute a continue statement inside your return statement. This is a really bad thing that can cause a lot of problems.
The issue here is that every time a continue statement is used in a return statement, it’s executing that return statement. This is considered the best practice for programming because the problem statement is not only the last statement in a block, but it also always executes the return statement. So the statement that is following the continue statement is ignored. While this is a problem, it’s not fatal.
So inside a return statement is not an issue. But inside a continue statement (which is the problem statement) that would be a big problem. Which is why its so important to always execute the continue statement. This rule is also what I call “the continue statement rule” because it is the only rule that I know of that says that continue statements in the update statement always execute.
Yeah, sometimes you get this problem, especially when you write code that is not used in the update statement. But if you always execute the continue statement in the update statement, then you will never get this problem.