text: String containing first letter of every word in a given string with spaces | Java implementation of the above approach ; we are splitting the input based on spaces ( s ) + : this regular expression will handle scenarios where we have words separated by multiple spaces ; charAt ( 0 ) will pick only the first character from the string and append to buffer ; main function
code: class GFG { private static StringBuilder charBuffer = new StringBuilder ( ) ; public static String processWords ( String input ) { String s [ ] = input . split ( " ( \\ s ) + " ) ; for ( String values : s ) { charBuffer . append ( values . charAt ( 0 ) ) ; } return charBuffer . toString ( ) ; } public static void main ( String [ ] args ) { String input = " geeks ▁ for TABSYMBOL geeks ▁ geeks TABSYMBOL for ▁ geeks " ; System . out . println ( processWords ( input ) ) ; } }