java program to remove vowels from string using stringbuffer class

Solutions on MaxInterview for java program to remove vowels from string using stringbuffer class by the best coders in the world

showing results for - "java program to remove vowels from string using stringbuffer class"
Benjamin
06 Apr 2016
1// java program to remove vowels from a string using StringBuffer class
2import java.util.Arrays;
3import java.util.List;
4public class RemoveVowels
5{
6   static String removeVowel(String strVowel)
7   {
8      Character[] vowel = {'a', 'e', 'i', 'o', 'u','A','E','I','O','U'};
9      List<Character> li = Arrays.asList(vowel);
10      StringBuffer strBuffer = new StringBuffer(strVowel);
11      for(int a = 0; a < strBuffer.length(); a++)
12      {
13         if(li.contains(strBuffer.charAt(a)))
14         {
15            strBuffer.replace(a, a + 1, "") ;
16            a--;
17         }
18      }
19      return strBuffer.toString();
20   }
21   public static void main(String[] args)
22   {
23      String strInput = "Hello World Java";
24      System.out.println(removeVowel(strInput));
25   }
26}