Loops

Java Loops - 10 Cards
Click here to toggle all cards
Loop Statements
Loop Statements help you to repeat code execution
Types of Loop Statements
Different types of loops include for, while, and do-while loops
For Loop
Used to iterate a specific number of times
For Loop Syntax
for (initialization; condition; iteration) { // code to be executed }
While Loop
Repeatedly execute a block of code while a condition is true
While syntax
while (condition) { //code to be executed }
Do-While Loop
Executes the code block once before checking the condition
Do-While Syntax
do { // code to be executed } while (condition);
break Statement
Used to exit a loop or a switch statement
continue Statement
Used to skip over one iteration of a loop