Replace all consonants with nearest vowels in a string | Java program to replace all consonants with nearest vowels in a string ; Function to replace consonant with nearest vowels ; Driver code
import java . util . * ; class solution { static String replacingConsonants ( String s ) { String str = " aaaeeeeiiiiioooooouuuuuuuu " ; char [ ] st = s . toCharArray ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int index = st [ i ] - ' a ' ; st [ i ] = str . charAt ( index ) ; } String str1 = new String ( st ) ; return str1 ; } public static void main ( String arr [ ] ) { String s = " geeksforgeeks " ; System . out . println ( replacingConsonants ( s ) ) ; } }