how to remove a string off code example

Example 1: how to remove letters from string

public extractLetters(String str){
	String result="";
	for(int i= 0; i< str.length; i++){
	    if(Character.isLetter(str.charAt(i))){
	    result+=str.charAt(i);
	  	}
	}

Example 2: how to remove voules out of a string

import java.util.Scanner;
public class RemoveVowelsUsingMethod
{
   static String removeVowel(String strVowel)
   {
      Character[] chVowels = {'a', 'e', 'i', 'o', 'u','A','E','I','O','U'};
      List li = Arrays.asList(chVowels);
      StringBuffer sb = new StringBuffer(strVowel);
      for(int a = 0; a < sb.length(); a++)
      {
         if(li.contains(sb.charAt(a)))
         {
            sb.replace(a, a + 1, "");
            a--;
         }
      }
      return sb.toString();
   }
   public static void main(String[] args)
   {
      String strInput = "Flower Brackets";
      System.out.println(removeVowel(strInput));
   }
}

Tags:

Misc Example