17.5%-22.5%
iteration: repeating an action or set of actions until a given condition is met
// WHILE LOOP
code before loop
while (condition) {
do this while the condition is true
}
do this when the condition is no longer true
Infinite Loop Scenario:
Loop Condition Always False:
// Fixed Repetitions
int i = 0;
while (i < 5) {
System.out.println("hello");
i++;
}
hello
hello
hello
hello
hello
while (true) {
do something
if (certain condition is met) {
do something else
break;
}
do something if condition not met
}