while Repetition Statement
}Repetition statement—repeats an action while a conditionremains true.
}Pseudocode
While there are more items on my shopping list
Purchase next item and cross it off mylist
}The repetition statement’s body may be a single statement or a block.
}Eventually, the condition will become false. At this point, the repetition terminates, and the first statement after the repetition statement executes.
}Example of Java’s while repetition statement: find the first power of 3 larger than100. Assume int variable product is initialized to 3.
while ( product <= 100)
product = 3* product;
}Each iteration multiplies productby 3, so product takes on the values 9, 27, 81 and 243 successively.
}When variable product becomes 243, the while-statement condition—product<=100—becomes false.
}Repetition terminates. The final value ofproductis 243.
}Program execution continues with the nextstatement after the while statement.

while Repetition Statement
}Repetition statement—repeats an action while a conditionremains true. }Pseudocode
Whilethere are more items on my shopping list
Purchase next item and cross it off mylist
}The repetition statement’s body may be asingle statement or a block. }Eventually, the condition will becomefalse. At this point, the repetition terminates, and the first statement afterthe repetition statement executes.
}Example of Java’s whilerepetition statement: find the first power of 3 larger than100. Assume intvariable product is initialized to 3.
while ( product <= 100)
product = 3* product;
}Each iteration multiplies productby 3, so product takes on the values 9, 27, 81 and 243successively. }When variable productbecomes 243, the while-statementcondition—product<=100—becomes false. }Repetition terminates. The final value ofproductis 243. }Program execution continues with the nextstatement after the whilestatement.

while Repetition Statement
}Repetition statement—repeats an action while a conditionremains true. }Pseudocode
Whilethere are more items on my shopping list
Purchase next item and cross it off mylist
}The repetition statement’s body may be asingle statement or a block. }Eventually, the condition will becomefalse. At this point, the repetition terminates, and the first statement afterthe repetition statement executes.
}Example of Java’s whilerepetition statement: find the first power of 3 larger than100. Assume intvariable product is initialized to 3.
while ( product <= 100)
product = 3* product;
}Each iteration multiplies productby 3, so product takes on the values 9, 27, 81 and 243successively. }When variable productbecomes 243, the while-statementcondition—product<=100—becomes false. }Repetition terminates. The final value ofproductis 243. }Program execution continues with the nextstatement after the whilestatement.
