Java – Do while loop

PREV     NEXT

Do while loop is similar to that of the while loop except that the condition is evaluated at the end of the loop in do-while whereas in while loop, it is evaluated before entering into the loop.

Syntax:

do

{

//statements

}while(condition)

The statements given inside the ‘do’ block are executed at least once regardless of the condition.

Example:


COMPILE & RUN

Output:

Value: 0

Value: 1

Value: 2

Value: 3

Value: 4

Value: 5

PREV     NEXT


Share this website !!!
Facebook Twitter Linkedin