In this post, we will learn about while loop in java with an example
while is a keyword in java used to loop in condition-based
while(condition){
// your logic here
}
Example
public class WhileExample {
public static void main(String[] args) {
int i = 0;
while (i < 5) {
System.out.println("Loop Number " + i);
i++;
}
}
}
Output
while loop using boolean datatype in java
https://beginnersbug.com/while-loop-using-boolean-datatype-in-java/