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