Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 4, 2018 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/031618e3dafb722b664cfc37ee614039 to your computer and use it in GitHub Desktop.
Save thmain/031618e3dafb722b664cfc37ee614039 to your computer and use it in GitHub Desktop.
public class RemoveVowels {
public void removeVowels(String input){
StringBuffer result = new StringBuffer();
char[] chars = input.toCharArray();
for (int i = 0; i <chars.length ; i++) {
char chr = chars[i];
if(!isVowel(chr))
result.append(chr);
}
System.out.println("Updated String: " + result);
}
public boolean isVowel(char chr){
String vowels="AEIOUaeiou";
if(vowels.contains(chr+""))
return true;
else
return false;
}
public static void main(String[] args) {
RemoveVowels r = new RemoveVowels();
String input = "algorithms @ tutorial horizon";
System.out.println("Input String: " + input);
r.removeVowels(input);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment