I was wondering if someone could help me go through my wrong logic in this code. I am trying to take a string and remove all the vowels using a recursive method.
My reasoning is that if the character at beginning of string is not "a" then it'll execute the else statement and make the sentence one character shorter. Once it reaches an "a", it'll remove it and make the string one letter shorter.
Code:
# public static void RemoveVowels(String str)
# if (str.substring(0,1).compareToIgnoreCase("a" == 0))
# {
# str.replace("a", "");
# RemoveVowels(str.substring(1));
# }
# else
# RemoveVowels(str.substring(1));
My reasoning is that if the character at beginning of string is not "a" then it'll execute the else statement and make the sentence one character shorter. Once it reaches an "a", it'll remove it and make the string one letter shorter.