Program to accept Strings starting with a Vowel | Java program to accept String starting with Vowel ; Function to check if first character is vowel ; Function to check ; Driver code
class GFG { static int checkIfStartsWithVowels ( char [ ] str ) { if ( ! ( str [ 0 ] == ' A ' str [ 0 ] == ' a ' str [ 0 ] == ' E ' str [ 0 ] == ' e ' str [ 0 ] == ' I ' str [ 0 ] == ' i ' str [ 0 ] == ' O ' str [ 0 ] == ' o ' str [ 0 ] == ' U ' str [ 0 ] == ' u ' ) ) return 1 ; else return 0 ; } static void check ( String str ) { if ( checkIfStartsWithVowels ( str . toCharArray ( ) ) == 1 ) System . out . print ( "Not AcceptedNEW_LINE"); else System . out . print ( "AcceptedNEW_LINE"); } public static void main ( String [ ] args ) { String str = " animal " ; check ( str ) ; str = " zebra " ; check ( str ) ; } }