We would like to use while loop to count from one to ten.
Output should like this:
1 2 3 4 5 6 7 8 9 10
// Counter-controlled repetition with the while repetition statement. public class Main { public static void main(String[] args) { /*from w w w .j a va 2 s . c om*/ int counter = 1; // declare and initialize control variable //your code here System.out.println(); } }
// Counter-controlled repetition with the while repetition statement. public class Main { public static void main(String[] args) { int counter = 1; // declare and initialize control variable while (counter <= 10) // loop-continuation condition { System.out.printf("%d ", counter); ++counter; // increment control variable } System.out.println(); } }