Check Vowel or Consonant in Java
Program to check whether a character is alphabet, vowel, or consonant.
Last updated: 11 January 2026
Method 1: Using Switch Case
Check against vowels.
Main.javaRun in Compiler →
public class VowelConsonant {
public static void main(String[] args) {
char ch = 'i';
switch (ch) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println(ch + " is vowel");
break;
default:
System.out.println(ch + " is consonant");
}
}
}Output:
i is vowel
Explanation
Checks if char matches any vowel case. Otherwise assumes consonant.
Frequently Asked Questions
Try This Program
Copy this code and run it in our free online Java compiler.
Open Java Compiler