by Dinesh Thakur

In the switch statement, since same statements has to be executed corresponding to different cases ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') so we write the statements with the last case. The break statement causes the switch statement to terminate when any of the vowels is entered.

//Program to Check whether a Given Character is Vowel or Not

public class VowelorNot
{
         public static void main(String[] args)
     {
         char ch='z';
        
         switch(ch)
             {
                    case 'a': case 'A':
                    case 'e': case 'E':
                    case 'i': case 'I':
                    case 'o': case 'O':
                    case 'u': case 'U':
                                 System.out.println( ch + " is Vowel");
                                             break;  
                    default:
                                System.out.println( ch + " is not Vowel");
             }
                              
       }
}

Java Program Vowel or Not Example