- The class is declared as
Dowhileloop
.
- The
main
method is declared as public static void main(String[] args)
.
- An integer variable
i
is initialized with a value of 0.
- The do-while loop is started using the
do
keyword.
- Inside the loop, the current value of
i
is printed using System.out.println(i)
.
- The value of
i
is incremented by 1 using i = i + 1
.
- The condition
i < 11
is checked, and if it evaluates to true, the loop continues. Otherwise, the loop is terminated.
- Since the condition initially holds true (
0 < 11
), the loop will execute until i
becomes 11.
- Once
i
reaches 11, the loop terminates, and the program ends
public class Dowhileloopaapnaclg {
public static void main(String[] args){
int i = 0;
do {
System.out.println(i);
i = i + 1;
}
while (i < 11);
}
}