Limited access

Upgrade to access all content for this subject

You are provided with the following recursive function, which takes a String as input and returns a new String as a result:

public String modifyString(String s) {
    int length = s.length();

    if(length == 0)
        return "";

    return s.charAt(length - 1) + modifyString(s.substring(0, length - 1));

To test this function, you run the following command:

System.out.print(modifyString("Hello world!"));
Select an assignment template