Skip to content

Continue Statement

ContinueStmt Entity

In Java, the continue statement is used within loops (for, while, do-while) to skip the rest of the current iteration and immediately jump to the next iteration of the loop. When encountered, it stops the current iteration and continues with the next one, bypassing any code that comes after the continue statement within the loop body. This is particularly useful when you want to skip specific iterations based on certain conditions while allowing the loop to continue its normal execution for other cases.

Example

for (int i = 0; i < 10; i++) {
if (i == 5) {
continue; // ContinueStmt
}
// Code to be executed for all iterations except when i is 5
}

Attributes

MethodDescription
GetAPrimaryQlClass() stringReturns the primary CodeQL class name for this entity
GetHalsteadID() intReturns the Halstead ID metric for this continue statement
GetLabel() stringGets the label associated with this continue statement if any
hasLabel() boolChecks if this continue statement has a label attached to it
GetPP() stringReturns the pretty-printed representation of this statement
ToString() stringReturns a string representation of the continue statement