Java programming language provides the following types of loop to handle looping requirements.
(i) while loop – Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.
while(condition) {
// Statements
}
Reference video: java while loop
(ii) for loop – Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable.
for(initialization; condition; update) {
// Statements
}
Reference video: java for loop
(iii) do…while loop – Like a while statement, except that it tests the condition at the end of the loop body.
do {
// Statements
}while(condition);
Reference video: java do while loop