Loops repeatedly executes the same set of instructions until a termination condition is met.
We have three loops in Java
for Loop In Java
for(initialization; condition; iteration)Working : When the loop first starts, the initialization portion is executed. Next, condition is evaluated. If the condition is true, then the body of the loop is executed.If it is false, the loop terminates. Next, the iteration portion of the loop is executed.
while Loop In Java
While loop is Java's most fundamental loop statement. It repeats a statement or block untill the controlling expression is true.
while(condtion)do while Loop In Java
//body of loop
// body of loop
} while (condition);