break

A break statement lets you end an iterative (do, for, while) or switch statement and exit from it at any point other than the logical end.

In an iterative statement, the break statement ends the loop and moves control to the next statement outside the loop. Within nested statements, the break statement ends only the smallest enclosing do, for, switch, or while statement.

In a switch body, the break passes control out of the switch body to the next statement outside the switch body.

Restrictions
A break statement can appear only in the body of an iterative statement or a switch statement.



Examples Using the break Statement


do Statement
for Statement
switch Statement
while Statement