Exit Controlled Loop in Java

Below is the implementation of Exit Controlled Loop in Java:

Java
/*package whatever //do not write package name here */

import java.io.*;

class GFG {
    public static void main(String[] args)
    {
        int i = 5;
        // Exit Controlled Loop
        do {
            System.out.println(i);
            i--;
        } while (i < 5 && i > 0);
    }
}

Output
5
4
3
2
1

Exit Controlled Loop in Programming

Exit controlled loops in programming languages allow repetitive execution of a block of code based on a condition that is checked after entering the loop. In this article, we will learn about exit controlled loops, their types, syntax, and usage across various popular programming languages.

Similar Reads

What are Exit Controlled Loops?

Exit Controlled loops are loop structures where the loop’s condition is checked after the loop body has executed. This means that the loop will always execute at least once, regardless of whether the condition is true or false initially. The most common examples of exit-controlled loops are the do-while loop in languages like C, C++, and Java....

Exit Controlled Loop in C:

Below is the implementation of Exit Controlled Loop in C:...

Exit Controlled Loop in C++:

Below is the implementation of Exit Controlled Loop in C++:...

Exit Controlled Loop in Java:

Below is the implementation of Exit Controlled Loop in Java:...

Exit Controlled Loop in C#:

Below is the implementation of Exit Controlled Loop in C#:...

Exit Controlled Loop in JavaScript:

Below is the implementation of Exit Controlled Loop in JavaScript:...

Exit Controlled Loop in Python :

Below is the implementation of Exit Controlled Loop in Python :...

Comparison with Entry-Controlled Loops:

Entry-Controlled Loop (e.g., while, for loops): The condition is checked before the loop body executes. If the condition is false initially, the loop body may not execute at all....