CS2
Recursion
15
Example
nWhat does the method funny return, in terms of its argument? This code does compile and run.
Recall that substr(a, b)creates a string from the original, using indices from A to b-1 .
   private static String funny( String thing ) {
        String result = thing;
        int last = thing.length() - 1;
        if ( last > 0 ) {
            result = thing.charAt( last )
                     + funny( thing.substring( 0, last ) );
        }
nShow the output that would result from executing the following instruction in the "main" method: System.out.println( funny("hello") );
nReturns the entire string, with the characters in reverse order.