to count total number of consonants from 0 to n - 1
static int totalConsonants ( String str , int n ) { if ( n == 1 ) { if ( isConsonant ( str [ 0 ] ) ) return 1 ; else return 0 ; } if ( isConsonant ( str [ n - 1 ] ) ) return totalConsonants ( str , n - 1 ) + 1 ; else return totalConsonants ( str , n - 1 ) ; }