break
: First, more than one
break
statement
may appear in a loop. However, be careful. Too many
break
statements have the tendency
to destructure your code. Second, the
break
that exits a
switch
statement affects only that
switch
statement and not any enclosing loops.
Using continue
It is possible to force an early iteration of a loop, bypassing the loop’s normal control structure.
This is accomplished using
continue
. The
continue
statement forces the next iteration of the
loop to take place, skipping any code in between. Thus,
continue
is essentially the complement
of
break
. For example, the following program uses
continue
to help print the even numbers
between 0 and 100.
www.freepdf-books.com
Do'stlaringiz bilan baham: |