Question: Hello ! here is a question to be solved in java : Write a recursive method called countdown that accepts one integer parameter and prints
Hello !
here is a question to be solved in java :
Write a recursive method called countdown that accepts one integer parameter and prints a rocketship countdown from that number. For example, if the parameter is 5, the output should be 5-4-3-2-1-Blastoff!. You can assume the parameter is non-negative.
here is the code I wrote for it :
public static void countdown (int n ) { if (n == 1) { return"Blastoff!";} else { return n + "" + countdown (n-1);} }
here is the error I get for it :
You didn't declare a method called countdown that has a single int parameter.
The method doesn't contain a recursive call to countdown.
Why am I getting this error ?
Thank you !
You didn't declare a method called countdown that has a single int parameter.
The method doesn't contain a recursive call to countdown.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
