While statement executes a statement or a block of statements until a specified expression evaluates to false.
A while loop can be terminated with
- break
- goto
- return
- throw
Example:
int i = 0;
while (i < 10){
if (i == 1)
{
i = 2;
continue; // goto to next loop
}
if (i == 2)
return; // exit while
if (i==5)
break; // exit while
i= i + 1;
}