Count of substrings consisting only of vowels | Java program to count all subStrings in a String which contains only vowels ; Function to check if a character is vowel or not ; Function to check whether String contains only vowel ; Check if the character is not vowel then invalid ; Function to Count all subStrings in a String which contains only vowels ; Generate all subString of s ; If temp contains only vowels ; Increment the count ; Driver code
import java . util . * ; class GFG { static boolean isvowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } static boolean isvalid ( String s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! isvowel ( s . charAt ( i ) ) ) return false ; } return true ; } static int CountTotal ( String s ) { int ans = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp += s . charAt ( j ) ; if ( isvalid ( temp ) ) ans += 1 ; } } return ans ; } public static void main ( String [ ] args ) { String s = " aeoibsddaaeiouudb " ; System . out . print ( ( CountTotal ( s ) ) + "NEW_LINE"); } }