Write Simple Java Program For While Loop :
Here is Simple Java Program For the "While" Loop:
public class WhileLoopExample {
public static void main(String[] args) {
int count = 1;
while (count < 11) {
System.out.println("Count is: " + count);
count++;
}
}
}
This program will output the following:
Count is: 1
Count is: 2
Count is: 3
Count is: 4
Count is: 5
Count is: 6
Count is: 7
Count is: 8
Count is: 9
Count is: 10
The
While loop will continue to execute as long as the condition count < 11 is true. The value of count is incremented by 1 each time the loop iterates, so eventually the condition will become false and the loop will terminate.-----------------------------------------------------------------------------------
0 Comments