-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoWhile.java
More file actions
24 lines (21 loc) · 802 Bytes
/
Copy pathDoWhile.java
File metadata and controls
24 lines (21 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class DoWhile {
public static void main(String[] args) {
int i =8;
do
{
System.out.println("i is : " + i);
i++;
} while(i < 1);
}
}
//Output: i is : 1
//variable i is set to 1
//the do block executes and prints the value of i.
//this is true for any int entered as a value for i
//The do/while loop executes once, and then continues to repeat while true.
//The do/while loop is a one-to-many iterative loop:
//The condition is at the bottom of the loop and is processed after the body.
//The body of the loop is therefore processed at least once.
//If you want the statement, or statements, in the body to be processed at least once,
//use a do/while loop instead of while or for loop.
//The do/while loop is used to iterate indefinitely through statements one or more times.