Breaks are used to exit from an iteration directly.
EXAMPLE FOR USUALLY USED FORMULA:
Use when the condition can not be placed into the condition of the loop.
It harms the readable structure, avoid it if possible or use a temporary variable in the head of the loop which you manipulate in place of the break.
In case of nested loops, exits from the loop level you execute it from within.
Breaks are parts of the not-enhanced switch statement.
With a label, we can control where should the break move the flow.
Use it from nested loops where exiting the inner loop is not enough.
EXAMPLE FOR USUALLY USED FORMULA:
A text following by a : sign is a label.
The label marks the iteration from which the break should jump out.
The text "label" can be choosen by developer for better understanding the reason or the position.
More than one label can be placed alongside a nested loop.
Ruins the readable structure more since a loop is identified and followed by its header and its condition which can become unreadable by using cross-jumpings through codes.
EXAMPLE FOR USING BREAK IN A COMPLEX WAY:
The "continue" statement skips the actual loop turn, moves to the end of the cycle but stays within the loop.
Always use it in an if statement.
EXAMPLE FOR ADDING ONLY EVEN NUMBERS UNTIL 1000 BUT PASSES [500..600] INTERVAL:
Again, ruins the structure, avoid if possible.
In nested loops, navigates only in the loop it was executed.
The "labeled continue" works similarly to the labeled break: the "continue" will make the flow skip until the end of the labeled iteration.
EXAMPLE FOR USUALLY USED FORMULA: