Title: Key Concept - While and Do-While Statements
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: Learning Modules

The while statement repeats execution of a block of code until a boolean expression is false.

The while statement syntax:

while (<boolean-expression>)
{
<block>
}

- The while statement tests the boolean expression before execution of the block.
- The block will execute zero or more times.

The do-while statement also repeats execution of a block of code until a boolean expression is false.

The do-while statement syntax:

do
{
<block>
} while (<boolea-expression>);

- The do-while statement tests the boolean expression after execution of the block.
- The block will execute one or more times.

For additional study, view the resources under:

- Level 1 Study Materials: Unit 3
- Level 1 Study Materials: Unit 4