As you know, a very long stack may lead to StackOverflowError.
In this problem, you need to invoke a method to create the shortest stack. Your program should print "Hello" exactly three times.
public class MyClass {
public static void main(String args[]) {
// What to invoke here to get the shortest stack?
}
public static void f() {
System.out.println("Hello!");
q();
}
public static void g() {
System.out.println("Hello!");
System.out.println("Hello!");
System.out.println("Hello!");
}
public static void h() {
g();
}
public static void q() {
System.out.println("Hello!");
System.out.println("Hello!");
}
}