The do Statement - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript The do Statement - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Monday, March 25, 2019

The do Statement

The do Statement
üThe do statement has the following syntax:


do and

while are
reserved
words

do{
    statement;
} while (condition);

The statement is executed once initially,

and then the condition is evaluated

The statement is  executed repeatedly
until the condition becomes false

do-while Example

final int LIMIT = 5;


int count = 1;

do {

    System.out.println(count);

    count += 1;

} while (count <= LIMIT);

Output:

1
2
3
4
5

Comparing while and do


No comments:

Post a Comment

Post Top Ad