continue

Restarts a while, do-while, for, or label statement.

Syntax

continue [label]

Parameter

label Identifier associated with the label of the statement.

Description

In contrast to the break statement, continue does not terminate the execution of the loop entirely: instead,

  • In a while loop, it jumps back to the condition.
  • In a for loop, it jumps to the update expression.

The continue statement can now include an optional label that allows the program to terminate execution of a labeled statement and continue to the specified labeled statement. This type of continue must be in a looping statement identified by the label used by continue.

Examples

Example 1. The following example shows a while loop that has a continue statement that executes when the value of i is 3. Thus, n takes on the values 1, 3, 7, and 12.

See also

break, label

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.