how to add spaces into a string java after removing spaces code example Example: java 8 remove spaces from string a.replaceAll("\\s+","");