Blog

While Loop in Java | Basic Java TUTORIAL

In the previous session we described about for loop [ Link ] and now it’s turn to describe about While loop in java.

While loop is the type of looping structure in which you can able to execute a block of code or statements multiple times.

Syntax for while Loop

while(Boolean_expression) {
   // Statements
}

Example to demonstrate the While loop

package practice_08;
public class WhileLoop 
{
    public static void main(String[] args) 
    {
      int i =0;
      while(i<=10)
      {
          System.out.println("Inside while loop");
          i++;
          
      }
        System.out.println("Outside of while loop");
    }
    
}