Example: reverse string
// Return the reverse of string s. For example, if s is
// �abcd�, return the string �dcba�.
public static String rev(String s) {
// If the string is empty or contains one character, return it
if (s.length( ) <= 1) return s;
// The string has the form C c, where C is a character;
// c is a string. C is s.charAt(0). c is s.substring(1).
// Return the reverse of c catenated with C
return rev(s.substring(1)) + s.charAt(0);