|
|
![]() | Syntax: do Statement
while ( Expression );
|
![]() | Semantics:
The statement is executed first and then the expression
is evaluated which must be of boolean type.
As long the expression remains true,
the statement is executed repeatedly.
|
![]() | Note: The while statement evaluates the
condition first and then, as long it remains true, executes
the statement repeatedly. In case of the do statement
the condition is not evaluated before the first iteration
is performed.
|
![]() | Following layout conforms to our coding standard:
do { |
| Heron.java |
// read in x
do {
x = RitIo.getDouble("x: ");
if (x < 0) {
System.out.println("No real-valued results!");
System.out.println("Please give a non-negative"
+ " number.");
}
} while (x < 0);
|
|
| Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002 |