public class Main { public static void main(String[] args) { NotStatic g = new NotStatic(); String sentence = "This is my example sentence."; String s = g.RemoveVowelsFromSentence(sentence); System.out.println(s); // output: // Ths s m xmpl sntnc. } } class NotStatic { public String RemoveVowelsFromSentence(String sentence) { String[] vowels = {"a", "e", "i", "o", "u", "y"}; // iterate through the vowel array with for-each for (String s:vowels){ sentence = sentence.replaceAll(s, ""); } return sentence; } }
Friday, September 25, 2009
Java - remove vowels from a sentence String
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment