how to get ride of white spaces in string code example Example: remove space string java a = a.replaceAll("\\s+", "");