Program to count vowels in a string ( Iterative and Recursive ) | Java program to count vowels in a string ; Function to check the Vowel ; Returns count of vowels in str ; if ( isVowel ( str . charAt ( i ) ) ) Check for vowel ; Driver code ; string object ; Total numbers of Vowel
public class GFG { static boolean isVowel ( char ch ) { ch = Character . toUpperCase ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } static int countVowels ( String str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) ++ count ; return count ; } public static void main ( String args [ ] ) { String str = " abc ▁ de " ; System . out . println ( countVowels ( str ) ) ; } }