how to remove all whitespace from string java

Java
st = st.replaceAll("\\s+","")
Source

Also in Java: