One of the Java questions I faced is to create a program which prints 1000 Hello World without using loop. So how do we solve this? The solution is to use recursion!
public class HelloWorld {
public static void main(String[] args) {
printThousandHelloWorld(1);
}
private static void printThousandHelloWorld(int n) {
if(n < 1000) {
printThousandHelloWorld(n+1);
}
System.out.println("Hello World");
}
}