Day 16:
Looping Statements
Looping statement are the execution of the block of code repeatedly until we break it.
for Loop
Executes a block of code a specific number of times until the condition is true or a n number of times with the initialization, condition and increment/decrement.
Syntax:
Example:
While Loop
Executes a block of code as long as the condition is true.
A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
Example:
领英推荐
Do while
Executes the loop body at least once before checking the condition. Do while loop is similar to while loop with only difference that it checks for condition after executing the statements, and therefore is an example of Exit Control Loop.?
Example:
For Each Loop/Enhanced For loop:
To iterate over the arrays or collections we use this For each loop. As name says it just loop arrays as single element.
Syntax:
Example:
Let's run through the Jump statements tomorrow. Happy Learning