Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

Write a Java program to demonstrate While Loop?

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++;
    }
  }
}
LambdaTest

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing
LambdaTest

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More
LambdaTest

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS

Support

24/7 support

Security

Enterprise grade security

Cloud

Fastest test execution cloud