Write a recursive method that will duplicate each character in a string and return the result as a new string. For example, if "book" is the argument, the result would be "bbooookk".
What will be an ideal response?
```
public static String doubleEachLetter(String s){
String result;
if(s.length() == 0)
result = "";
else {
String doubled = "" + s.charAt(0) + s.charAt(0);
result = doubled + doubleEachLetter(s.substring(1));
}
return result;
}
```
This code is in Methods.java.
Computer Science & Information Technology
You might also like to view...
What is the different between a goal and a task? How do they relate to technology?
What will be an ideal response?
Computer Science & Information Technology
You write your letter and insert merge fields in step ____ of the mail merge process.
A. 1 B. 3 C. 4 D. 5
Computer Science & Information Technology