Created
June 4, 2018 02:34
-
-
Save thmain/031618e3dafb722b664cfc37ee614039 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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