public class WhileCounter
1: // Fig. 5.1: WhileCounter.java
2: // Counter-controlled repetition with the while repetition statement.
3:
4: public class WhileCounter
5: {
6: public static void main( String args[] )
7: {
8: int counter = 1; // declare and initialize control variable
9:
10: while ( counter <= 10 ) // loop-continuation condition
11: {
12: System.out.printf( "%d ", counter );
13: ++counter; // increment control variable by 1
14: } // end while
15:
16: System.out.println(); // output a newline
17: } // end main
18: } // end class WhileCounter
19:
20: /**************************************************************************
21: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
22: * Pearson Education, Inc. All Rights Reserved. *
23: * *
24: * DISCLAIMER: The authors and publisher of this book have used their *
25: * best efforts in preparing the book. These efforts include the *
26: * development, research, and testing of the theories and programs *
27: * to determine their effectiveness. The authors and publisher make *
28: * no warranty of any kind, expressed or implied, with regard to these *
29: * programs or to the documentation contained in these books. The authors *
30: * and publisher shall not be liable in any event for incidental or *
31: * consequential damages in connection with, or arising out of, the *
32: * furnishing, performance, or use of these programs. *
33: *************************************************************************/