|
|
|
/* ---------------------------------- Meaning of the while-statement: ---------------------------------- */ as long as ( loop-continuation-condition is true ) execute ONE-statement; |
Explanation:
|
|
|
public class While01 { public static void main(String[] args) { int a; a = 1; while ( a <= 10 ) // While-statement { System.out.println(a); // Print a a++; // Increment a } System.out.println("Done"); System.out.println("Exit: a = " + a); } } |
|
How to run the program:
|
1 2 3 4 5 6 7 8 9 10 Done Exit: a = 11 |
|
a = 1; while ( a <= 10 ) { System.out.println(a); a++; } System.out.println("Done"); |
Flow chart of this program:
|
|
How to "read" the diagram:
|
a = 1; while ( a <= 10 ) { System.out.println(a); a++; } System.out.println("Done"); |
Structure diagram of this program:
|