Java Program to Check Whether an Alphabet is Vowel or Consonant

In this example, we are giving a program to check wheather an alphabet is vowel or consonant.


To check an alphabet is vowel or consonant:

  1. # To check an alphabet is vowel or consonant
  2. public class VowelConsonant {
  3. public static void main(String[] args) {
  4. char ch = 'o';
  5. if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
  6. System.out.println(ch + " is vowel");
  7. else
  8. System.out.println(ch + " is consonant");
  9. }
  10. }

Output:

o is vowel