Answers for "how to check whether a character is vowel in java"

1

how to check whether a character is vowel in java

public class CodeGrepper {
    public static boolean isVowel(char letter) {
        String vowels = "aeouiAEOUI";
        return vowels.indexOf(letter) != -1; 
    }
    public static void main(String[] args) {
        System.out.println(isVowel('a')); // true
        System.out.println(isVowel('z')); // false
    }
}
Posted by: Guest on April-07-2022
-1

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);
         }
      }
   }
}
Posted by: Guest on November-06-2021

Code answers related to "how to check whether a character is vowel in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language