You are here: Home / Topics / Do while Loop example in Java

Do while Loop example in Java

Filed under: Java on 2023-08-18 07:00:44

// Do while example

class  DoWhileTest
{
public static void main( String args[ ] )
{
 int   i = 1; // 1.  Initialization
 do
 {
  System.out.print( "  " + i );
  i++; // 3.  Increment.
 }while ( i <= 5 ); // 2.  Test / Condition
}
}


Output:

 1  2  3  4  5

About Author:
Y
Yatendra Sir     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.