Write a recursive method that will reverse the order of the characters in a given string and return the result as a new string. For example, if "book" is the argument, the result would be "koob".
What will be an ideal response?
```
public static String reverse(String s){
String result;
if(s.length() == 0)
result = "";
else {
result = reverse(s.substring(1)) + s.charAt(0);
}
return result;
}
```
This code is in Methods.java.
You might also like to view...
What is a PID number? Why are these numbers useful when you run processes in the background? Which utility displays the PID numbers of the commands you are running?
What will be an ideal response?
Titles, instructions, command buttons, and other controls added to the bottom of a form and that remain on the screen when the form is displayed in Form view or Layout view are added to the ____ section of the form.
A. Form Footer B. Form Header C. Details D. Form Grid
Which of the following operators has the highest order of precedence?
A. () B. ++ C. % D. -
Which of the following correctly represents the expression a = a + 3?
a) 3a b) a += 3 c) a + 3 d) None of the above.