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.
Computer Science & Information Technology
You might also like to view...
If a field may require more than 255 characters, choose the ________ data type
Fill in the blank(s) with correct word
Computer Science & Information Technology
To insert a comment into a cell, you click New Comment in the ________ tab
A) Comments group on the Insert B) Documentation group on the Insert C) Documentation group on the Review D) Comments group on the Review
Computer Science & Information Technology