1/*2 * RemoveVowels.java3 *4 * Computer Science E-22/S-225 *6 * A class that contains a recursive method for removing all7 * lower-case vowels that appear in a string.8 * 9 * The main method includes two examples of using this method.10 */11 12public class RemoveVowels {13 /*14 * removeVowels - a recursive method that returns 15 * string formed by removing all lower-case vowels16 * (a, e, i, o, u) from the String s.17 * 18 * assumption: s refers to a String composed of 19 * 0 or more lower-case letters20 */21 public static String remVowels(String s) {22 if (s.equals("")) {23 return "";24 } else {25 // Make a recursive call to remove vowels from the26 // rest of the string.27 String remRest = remVowels(s.substring(1));28 29 // If the first character in s is a vowel,30 // we don't include it in the return value.31 // If it isn't a vowel, we do include it.32 char first = s.charAt(0);33 if (first == 'a' || first == 'e' || first == 'i'34 || first == 'o' || first == 'u') {35 return remRest;36 } else {37 return first + remRest;38 }39 }40 }41 42 public static void main(String[] args) {43 System.out.print("removing vowels from after: ");44 System.out.println(remVowels("after"));45 46 System.out.print("removing vowels from recurse: ");47 System.out.println(remVowels("recurse"));48 }49}