how to remove spaces from string in java using string builder code example Example: java 8 remove spaces from string a.replaceAll("\\s+","");