Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

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

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...
ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free