Remove spaces from a given string | Java program to remove all spaces from a string ; Function to remove all spaces from a given string ; Driver Code
class GFG { static String removeSpace ( String str ) { str = str . replaceAll ( " \\ s " , " " ) ; return str ; } public static void main ( String args [ ] ) { String str = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " ; System . out . println ( removeSpace ( str ) ) ; } }