OK so in a second thought after thinking about it for a while yesterday,
i've realized what was really bothering me in that question,
and it is the usage of break and continue statements in an if-else block,
which is forbidden in java. But it is ok to use break and continue inside an if-else block
when the block is in a for loop. Then i looked at the jls
where it discusses those issues (14.15 & 15.16), where it says almost the same
about those two statements, except for their actual action of course,
and that the continue statement can not be used in a switch block.
anyhow i've decided to quote here the relevant lines from the jls:
14.15 The break Statement
A break statement transfers control out of an enclosing statement.
BreakStatement:
break Identifier (opt) ;
A break statement with no label attempts to transfer control to the innermost
enclosing switch, while, do, or for statement of the immediately enclosing
method or initializer; this statement, which is called the break target, then
immediately completes normally.
To be precise, a break statement with no label always completes abruptly, the
reason being a break with no label.
If no switch, while, do, or for statement in the immediately enclosing method,
constructor, or initializer contains the break statement, a compile-time error
occurs.
and this one is about the continue statement:
A continue statement with no label attempts to transfer control to the innermost
enclosing while, do, or for statement of the immediately enclosing method,
constructor, or initializer; this statement, which is called the continue target, then
immediately ends the current iteration and begins a new one.
To be precise, such a continue statement always completes abruptly, the reason
being a continue with no label.
If no while, do, or for statement of the immediately enclosing method, constructor,
or initializer contains the continue statement, a compile-time error occurs.