Sunteți pe pagina 1din 9

Loops

Jayleen Elifonzo and Skye Jimenez


Loops
● Functions that repeat until condition’s met.
○ While Loop
○ For Loop
○ Do...While Loop
○ Nested Loop
While Loops
- Represents statements
until condition is true.
For Loop
The for loop has 3 different Elements

● Controls variable
● Test control variable
● Update control variable
For Loops
A For Statement has the following syntax:

For ( initialization ; condition ; increment )

Statement;

}
For Loops
for(int count = 0; count < 5; count++)
System.out.println("Hello!");

● This will print “Hello!” 5 times.


Do… While Loops
- Like a while loop, but
- Tests the condition at the end.
Nested Loops
- A loop inside another loop.
- Useful when displaying
multidimensional data.
- 1st iteration of first loop will
initialize.
- 2nd loop finishes
Thank you!

S-ar putea să vă placă și