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

My name is Eric.Am a software developer with skills in Php,Mysql, Java , Android,Node.js Above all, I have certification in Cisco Networking Associate (CCNA) and holds degree in Information Technology. Hire me: Email : kawi3462@gmail.com