logo image

Java program to print numbers from 1 to 10 using while loop



Following program shows you how to print numbers from 1 to 10 using while loop.

public class Basic7 {

	public static void main(String[] args) {

		int input = 1;

		while (input <= 10) {

			System.out.println(input);

			input++;
		}

	}

}

Output:

1
2
3
4
5
6
7
8
9
10