get rid of spaces in string java 8 code example Example: java 8 remove spaces from string a.replaceAll("\\s+","");