how to check whether a character is vowel in java

109

check vowel present in string java -

public class FindingVowels {
   public static void main(String args[]) {

      String str = new String("Hi Welcome to Tutorialspoint");
      for(int i=0; i<str.length(); i++) {
         if(str.charAt(i) == 'a'|| str.charAt(i) == 'e'|| str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u') {
            System.out.println("Given string contains "+str.charAt(i)+" at the index "+i);
         }
      }
   }
}

Comments

Submit
0 Comments