remove spaces from string java without using inbuilt function code example Example: java 8 remove spaces from string a.replaceAll("\\s+","");