// first: returns the first character of the given String public static char first (String s) { return s.charAt (0); } // last: returns a new String that contains all but the // first letter of the given String public static String rest (String s) { return s.substring (1, s.length()); } // length: returns the length of the given String public static int length (String s) { return s.length(); }
String backwards = reverseString ("Allen Downey"); System.out.println (backwards);should be
yenwoD nellA