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.
You might also like to view...
Data stored __________ disappears once the program stops running or the computer is powered down.
a. on a CD b. in RAM c. on a flash drive d. on the disk drive e. None of these
A small box with an upward- and downward-pointing arrow that enables you to move rapidly through a set of values by clicking.
What will be an ideal response?
Which of the principles of security is supported by hashing?
a. Availability b. Confidentiality c. Integrity d. Safety
Define a mixed symbol instance set.
What will be an ideal response?