Next-Gen App & Browser
Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles
While Loop is a control flow statement that lets you execute code repeatedly until a given Boolean condition becomes true, the loop stops when the Boolean condition becomes false.
Syntax
while (condition) {
// code block to be executed
increment / decrement statement
}
Example
The below Java program prints numbers from 1 to 10.
class OneToFive {
public static void main(String[] args) {
int i = 1, k = 10;
while(i <= k) {
System.out.println(i);
i++;
}
}
}
KaneAI - Testing Assistant
World’s first AI-Native E2E testing agent.