Java do-while loop

Java do-while Loop

Java do-while Loop is used to iterate program code several times.If the number of iteration are not fixed, the do-while loop is the best to use.

Do-while loop is first executed once before the condition is checked.

do-while Loop Syntax

Java do-while loop

Example

Output:

 

Infinitive Java do-while Loop

Infinitive do-while loop can be created by passing true as the condition.

Syntax:

 

Example:

Output:

The loop will continue running.Counting from 1 to infinity.

Next Topic: Java Break Statement

nextprevious

About the Author: Eric K

Kenyan Developer and Blogger with Interests in Java,Javascript,Node.js, Wordpress, Android, PHP and Making Money Online. Solving world problems through programming is my passion. Hire me: Email : kawi3462@gmail.com