Question
public static String mystery (String s) { char []temp = new char[1]; if (s.equals()) return; if(aeiouAEIOU.indexOf(s.charAt(0)) != -1) { temp[0]=s.charAt(0); return new String(temp) + mystery(s.substring(1));
public static String mystery (String s)
{
char []temp = new char[1];
if (s.equals("")) return"";
if("aeiouAEIOU".indexOf(s.charAt(0)) != -1)
{
temp[0]=s.charAt(0);
return new String(temp) + mystery(s.substring(1));
}
else return "" + mystery(s.substring(1));
}
a) show all the call to the function and what each one returns to its predecessor?
String result = mystery ("Omar");
Call#
1. mystery("Omar") returns ____ to result
2. mystery("___") returns _____ to Call ____
3. mystery ("__") returns ____ to Call #2.
4. mystery ("__") returns ____ to Call ___
5. mystery ("") returns "" to Call#4
b) Describe what the mystery method accomplishes
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started