/** * Write a description of class Examples here. * * @author John Paxton * @version 1.0 */ public class Examples { public int myLength (String word) { if (word.equals("")) { return 0; } else { return 1 + myLength(word.substring(1)); } } public void printReverse (String word) { for (int i = word.length() - 1; i >= 0; i--) { System.out.print(word.charAt(i)); } System.out.println(); } public void printReverseRecursively (String word) { if (word.equals("")) { // do nothing in the base case } else { printReverseRecursively (word.substring(1)); System.out.print(word.charAt(0)); } } public void reverseVersion2 (String word) { if (!word.equals("")) { System.out.print(word.charAt(word.length() - 1)); reverseVersion2(word.substring(0, word.length() - 1)); } } }