java tutorial - Java do while Loop - tutorial java - java programming - learn java - java basics - java for beginners

Java do while loop

Learn Java - Java tutorial - Java do while loop - Java examples - Javaprograms

Java do while Loop — It is similar to the while loop, the difference is that the do ... while loop is guaranteed to be executed at least one time.

 java do while loop

Learn java - java tutorial - java do while loop - java examples - java programs


The syntax of the do ... while loop in Java:

   // Operators
} while (Boolean expression);
click below button to copy the code. By - java tutorial - team
  • Note that the boolean expression appears at the end of the loop, so that the statements in the loop are executed once before being tested for the logical condition.
  • If the Boolean expression is true, the control jumps back to execute the operators, and they in the loop are executed again.
  • This process is repeated until the logical expression becomes false.

Process description


Learn java - java tutorial - loop-do-while - java examples - java programs

Sample Code

Below is an example of the do while code in Java:

public class Test {

   public static void main(String args[]){
      int x = 10;

         System.out.print(" Value y: " + x );
      } while( x < 15 );

click below button to copy the code. By - java tutorial - team


 Value y: 10
 Value y: 11
 Value y: 12
 Value y: 13
 Value y: 14

Related Searches to Java do while Loop