Remove consecutive vowels from string | Java program for printing sentence without repetitive vowels ; function which returns True or False for occurrence of a vowel ; this compares vowel with character ' c ' ; function to print resultant string ; print 1 st character ; loop to check for each character ; comparison of consecutive characters ; Driver Code
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static boolean is_vow ( char c ) { return ( c == ' a ' ) || ( c == ' e ' ) || ( c == ' i ' ) || ( c == ' o ' ) || ( c == ' u ' ) ; } static void removeVowels ( String str ) { System . out . print ( str . charAt ( 0 ) ) ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) if ( ( ! is_vow ( str . charAt ( i - 1 ) ) ) || ( ! is_vow ( str . charAt ( i ) ) ) ) System . out . print ( str . charAt ( i ) ) ; } public static void main ( String [ ] args ) { String str = " geeks ▁ for ▁ geeks " ; removeVowels ( str ) ; } }