Program to print numbers 1 to 10 without using loop in java

Let’s see Program to print numbers 1 to 10 without using loop in java.

package programnew;

public class PrintNum {
	public static void print(int n) {
		if (n <= 10) {
			System.out.println(n);
			print(n + 1);
		}
	}

	public static void main(String[] args) {
		print(1);

	}

}

Output is :-

1
2
3
4
5
6
7
8
9
10