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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!