Do-While loop
Do-While is an exit controlled loop. It means it will get executed at least once even if the test condition is false beacuse the test condition is checked inside the loop body.
Syntax:
Do-While is an exit controlled loop. It means it will get executed at least once even if the test condition is false beacuse the test condition is checked inside the loop body.
Syntax:
initialization do{ //code to be executed //update statement }while(condition);
Example:
public class DoWhileLoop { public static void main(String[] args) { int i=1; do{ System.out.println(i); i++; }while(i<=10); } }
Output:
1
2
3
4
5
6
7
8
9
10
No comments:
Post a Comment