/* Count controlled loop examples */ class Loop4 { public static void main(String [] args){ String space3 = " "; // Prints the numbers 1 to and including 10 int i = 1; while(i <= 10) { System.out.print(i + space3); i += 1; // Same as i = i + 1; } System.out.println(); // Count down from 10, stop at 1 int j = 10; while(j > 0) { System.out.print(j + space3); j -= 1; // Same as i = i - 1; } System.out.println(); // Print the numbers 1 to 10 except 5; int k = 1; while( k <= 10 ) { if ( k == 50) ++k; System.out.print(k + space3); ++k; } System.out.println(); } }