java program to remove white space without using replace() code example Example: how to remove all whitespace from string java st = st.replaceAll("\\s+","")