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

Post Top Ad

Post Top Ad

Monday, March 25, 2019

sUPERCODER%2BLOGO

The do Statement

The do Statement
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

Comparing%252Bwhile%252Band%252Bdo%252Bstatement%252Btrue%252Bfalse%252Bcondition%252Bevaluated

No comments:

Post a Comment

Post Top Ad