do a while loop in java
Code snippet on how to do a while loop in java
int i = 1;
while (i <= 10) {
System.out.println(i);
i++;
}
This code is a while loop that starts at 1 and increments the value of “i” by 1 until it is no longer less than or equal to 10. In each iteration, the current value of “i” is printed to the console. The loop ends when “i” has a value of 11, since 11 is not less than or equal to 10.